Here is a simple TList "class" i wrote some time ago for my needs of lists:

List.h
Code:
typedef struct TList
{
	int count;
	int* items;
	
}TList;

TList* list_create();
void list_free(TList* AList);

void list_add(TList* AList, void* AItem);
void list_remove(TList* AList, int AIndex);
int list_index_of(TList* AList, void* AItem);
void list_delete(TList* AList, void* AItem);
void list_clear(TList* AList);



List.c
Code:
TList* list_create()
{
	TList* LList = (TList*)sys_malloc(sizeof(TList));
	LList.count = 0;
	LList.items = NULL;
	return(LList);
}

void list_free(TList* AList)
{
	if (AList)
	{
		list_clear(AList);
		sys_free(AList);
	}
}




void list_add(TList* AList, void* AItem)
{
	AList.items = sys_realloc(AList.items, sizeof(int), AList.count, AList.count + 1);
	AList.count += 1;
	(AList.items)[AList.count - 1] = AItem;
}

void list_remove(TList* AList, int AIndex)
{

    int i;
    if(clamp(AIndex, 0, AList.count-1) == AIndex)
    {
        for (i = AIndex; i < AList.count-1; i++)
        {
            (AList.items)[i] = (AList.items)[i+1];
        }
        AList.items = sys_realloc(AList.items, sizeof(int), AList.count, AList.count-1);
        AList.count -= 1;
    }
}

int list_index_of(TList* AList, void* AItem)
{

    int i;
    int LResult = -1;
    for(i = 0; i < AList.count; i++)
    {
        if (AItem == (AList.items)[i])
        {
            LResult = i;
            break;
        }
    }
    return(LResult);
}

void list_delete(TList* AList, void* AItem)
{

    int LIndex = list_index_of(AList,AItem);
    if (LIndex >= 0)
    {
        list_remove(AList,LIndex);
    }
}

void list_clear(TList* AList)
{
	if(AList.items)
	{
		sys_free(AList.items);
		AList.items = NULL;
		AList.count = 0;	
	}
}



and the declaration of sys_realloc:
Code:
int* sys_realloc(void** AIn, int ASize, int AOldCount, int ANewCount)
{

    int i = 0;
    void** LOut;
    LOut = sys_malloc(ASize*ANewCount);
    for(i = 0; i < minv(AOldCount, ANewCount); i++)
    {
        (LOut)[i] = (AIn)[i];
    }
    sys_free(AIn);
    return(LOut);
}



this usually fullfills my needs of lists^^

Greetings
Rackscha


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development