#include "SutList.h"
int SutDeleteList(pSutList p);
p
is NULL, 0 otherwise.
SutDeleteList
deallocates the memory associated with a SutList
structure. The SutList structure and related functions manage a dynamically sized array of void pointers which can be used as a generic container for C/C++ programmers. The list must be deallocated with SutDeleteList()
or SutDestroyList()
. SutDeleteList
does not deallocate the memory associated with the elements themselves; the user is responsible for looping through the list and freeing each element.
#include "SutList.h"
#include <stdio.h>
pSutList list;
int i, size;
char *str;
char* str1 = "Hello";
char* str2 = "World";
list = SutNewList();
SutAddList(list, str1);
SutAddList(list, str2);
size = SutSizList(list);
for (i=0; i<size; i++)
{
str = (char*) SutGetNList(list, i);
fprintf(stderr, "%s\n", str);
}
SutDeleteList(list);