rendered paste body#include <list.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void ListRemoveIndex(List *list, int index)
{
*(list->hashTable + index) == NULL;
*(list->keysTable + index) == NULL;
if (index != list->size - 1)
{
printf("%x\n", list->hashTable + index);
memmove(list->hashTable + index, list->hashTable + index + 1, list->size - index);
//memmove(list->keysTable + index, list->keysTable + index + sizeof(int), list->size - index);
}
list->size--;
list->openSlots++;
}
int main(int argc, char **argv)
{
char o, t, th, f, fi;
o = 4;
t = 19;
th = 97;
f = 54;
fi = 32;
List l;
l.hashTable = (void **) malloc(10);
l.keysTable = (void **) malloc(10);
l.hashTable[0] = &o;
l.hashTable[1] = &t;
l.hashTable[2] = &th;
l.hashTable[3] = &f;
l.hashTable[4] = &fi;
ListRemoveIndex(&l, 2);
return 0;
}
HEADER:
#ifndef _LIST_H
#define _LIST_H
#ifndef LIST_BLOCK_SIZE
#define LIST_BLOCK_SIZE = 10
#endif
typedef struct _List
{
int size;
int openSlots;
void **hashTable;
void **keysTable;
} List;
void ListRemove(List *list, int index);
#endif