Hello, me again!
I am trying to write a function that I will be able to use to initialise the values of any type of data. Any opinions on this function.
Cheers.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
typedef struct Node NODE;
struct Node
{
int *pData;
NODE *pNext;
NODE *pPrev;
};
void init_list (void *, size_t);
int main(void)
{
NODE *pMylist;
if ((pMylist = (NODE *) malloc(sizeof(NODE))) == NULL)
{
printf("ERROR: Unable to allocate memory\n");
exit(1);
}
init_list(pMylist, sizeof(NODE));
free(pMylist);
return 0;
}
void init_list (void *pData, size_t size)
{
memset(pData, NULL, size);
}