Code:
#include <malloc.h>
You should just be using stdlib.h here instead.
Code:
struct process {
char name[5];
char type[4];
...
NULLPROCESS.name[0] = 'N','U','L','L';
NULLPROCESS.type[0] = 'N','U','L','L';
While this is technically legal, you go about using type as a string, which is is not with that assignment.
Code:
ITEMTYPE getLeastRemainingTime(struct node * h)
// Finds the node containing the process with the least remaining time.
// Deletes this node and returns the process
{
ITEMTYPE p = NULLPROCESS;
...
return p;
}
}
return NULLPROCESS;
}
That may as well just be return p, since you've already assigned it the values of NULLPROCESS.
I'm not really sure why you are returning structures by value here, and using pointers everywhere else. Also:
Code:
void del (struct node* h, struct node * current)
{
if(current == NULL)
...
else if(current->next == NULL && current->prev == NULL) // 1 item in list, just the head
{
h = NULL;
free(current);
}
else
{
if (current == h)
h = current->prev;
current->next->prev = current->prev;
current->prev->next = current->next;
free(current);
}
}
Both of those assignments are lost as soon as this function ends. You can never change the value of a passed argument directly and have it keep when the function ends. You need a pointer to a pointer.
Quzah.