Several problems I see:
accList_allocate
accList_allocate
doesn't do what you probably think. It creates a new accList
, yes, but this new one will not be visible to the caller (and thus, will be lost as memory leakage). If you want to initialize the pointer passed to it, use a pointer-to-pointer:
void accList_allocate(struct accList **outList) //allocate and initialize to NULL values
{
struct accList* theList = Malloc(sizeof(struct accList));
theList->head = NULL;
theList->tail = NULL;
theList->size = 0;
*outList = theList;
}
Also, you should really check the return value of Malloc
. Especially on embedded systems, there's a real possibility of running out of memory. Let the caller handle the error, but tell him that something's wrong.
appendToEnd
Same as with accList_allocate
, check Malloc
's return value and return some kind of error code if it's NULL. What you're writing there is library code that should always handle errors gracefully and let the caller decide whether to crash and burn or recover and try again.
removeData
Please refer to my answer in your other thread my answer in your other thread.
Several problems I see:
accList_allocate
accList_allocate
doesn't do what you probably think. It creates a new accList
, yes, but this new one will not be visible to the caller (and thus, will be lost as memory leakage). If you want to initialize the pointer passed to it, use a pointer-to-pointer:
void accList_allocate(struct accList **outList) //allocate and initialize to NULL values
{
struct accList* theList = Malloc(sizeof(struct accList));
theList->head = NULL;
theList->tail = NULL;
theList->size = 0;
*outList = theList;
}
Also, you should really check the return value of Malloc
. Especially on embedded systems, there's a real possibility of running out of memory. Let the caller handle the error, but tell him that something's wrong.
appendToEnd
Same as with accList_allocate
, check Malloc
's return value and return some kind of error code if it's NULL. What you're writing there is library code that should always handle errors gracefully and let the caller decide whether to crash and burn or recover and try again.
removeData
Please refer to my answer in your other thread.
Several problems I see:
accList_allocate
accList_allocate
doesn't do what you probably think. It creates a new accList
, yes, but this new one will not be visible to the caller (and thus, will be lost as memory leakage). If you want to initialize the pointer passed to it, use a pointer-to-pointer:
void accList_allocate(struct accList **outList) //allocate and initialize to NULL values
{
struct accList* theList = Malloc(sizeof(struct accList));
theList->head = NULL;
theList->tail = NULL;
theList->size = 0;
*outList = theList;
}
Also, you should really check the return value of Malloc
. Especially on embedded systems, there's a real possibility of running out of memory. Let the caller handle the error, but tell him that something's wrong.
appendToEnd
Same as with accList_allocate
, check Malloc
's return value and return some kind of error code if it's NULL. What you're writing there is library code that should always handle errors gracefully and let the caller decide whether to crash and burn or recover and try again.
removeData
Please refer to my answer in your other thread.
Several problems I see:
accList_allocate
accList_allocate
doesn't do what you probably think. It creates a new accList
, yes, but this new one will not be visible to the caller (and thus, will be lost as memory leakage). If you want to initialize the pointer passed to it, use a pointer-to-pointer:
void accList_allocate(struct accList **outList) //allocate and initialize to NULL values
{
struct accList* theList = Malloc(sizeof(struct accList));
theList->head = NULL;
theList->tail = NULL;
theList->size = 0;
*outList = theList;
}
Also, you should really check the return value of Malloc
. Especially on embedded systems, there's a real possibility of running out of memory. Let the caller handle the error, but tell him that something's wrong.
appendToEnd
Same as with accList_allocate
, check Malloc
's return value and return some kind of error code if it's NULL. What you're writing there is library code that should always handle errors gracefully and let the caller decide whether to crash and burn or recover and try again.
removeData
Please refer to my answer in your other thread.