This commit is contained in:
simon.kagstrom 2009-04-18 09:59:25 +00:00
parent 06992b8f2c
commit 218fba704c
2 changed files with 0 additions and 81 deletions

View File

@ -1,59 +0,0 @@
#include "slist.h"
/**********************************************************************************************************/
S_List *S_CreateList(int Sorted)
{
S_List *List;
List = (S_List*)malloc(sizeof(S_List));
if (!List)
return NULL;
List->Elements = 0;
List->List = NULL;
List->Sorted = Sorted;
return List;
}
/**********************************************************************************************************/
int S_AddToList(S_List* List, char *String)
{
char **NewList;
List->Elements++;
NewList = (char**)realloc(List->List, (size_t)(List->Elements * sizeof(char *)));
if (!NewList)
{
List->Elements--;
return 0;
}
List->List = NewList;
List->List[List->Elements - 1] = (char *)malloc((size_t)(strlen(String) + 1));
if (!List->List[List->Elements - 1])
{
List->Elements--;
List = (S_List*)realloc(List->List, (size_t)(List->Elements * sizeof(char *)));
return 0;
}
strcpy(List->List[List->Elements - 1], String);
return 1;
}
/**********************************************************************************************************/
void S_DestroyList(S_List* List)
{
int nCount;
if (List)
{
for (nCount = 0; nCount < (int)List->Elements; nCount ++)
{
if (List)
free(List->List[nCount]);
}
if (List->List)
free(List->List);
free(List);
List = NULL;
}
}

View File

@ -1,22 +0,0 @@
#ifndef __slist_h
#define __slist_h
struct _S_LIST
{
int Elements;
char **List;
int Sorted;
};
typedef struct _S_LIST S_List;
#define S_SORTED 1
#define S_UNSORTED 0
/************************************************************/
extern S_List* S_CreateList(int Sorted);
extern int S_AddToList(S_List *List, char *String);
extern void S_DestroyList(S_List *List);
/************************************************************/
#endif /* __slist_h */