Question: int List _ append ( List * pList, void * pItem ) { assert ( pList ! = NULL ) ; if ( pList -

int List_append(List* pList, void* pItem){
assert(pList != NULL);
if (pList->size >= LIST_MAX_NUM_NODES){
return LIST_FAIL; // List is full
}
int newNodeIndex = pList->available;
pList->available = pList->nodes[pList->available].next;
pList->nodes[newNodeIndex].data = pItem;
pList->nodes[newNodeIndex].next =-1; // No next node, as it is the last node
if (pList->size ==0){
pList->head = newNodeIndex;
} else {
int lastNodeIndex = pList->head;
while (pList->nodes[lastNodeIndex].next !=-1){
lastNodeIndex = pList->nodes[lastNodeIndex].next;
}
pList->nodes[lastNodeIndex].next = newNodeIndex;
}
pList->size++;
return LIST_SUCCESS;
} without malloc fix thisi code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!