Robert William Fuller wrote:
John Love-Jensen wrote:
Hi Robert,
Can you just get rid of the void** for the items parameter (see below)?
--Eljay
#include <stdlib.h>
int reallocItems(
void* items,
int itemSize,
int* itemAlloc,
int numItems,
int newItems,
int itemHint)
{
void* rcAlloc;
int emptyItems;
int allocItems;
// for idempotence
allocItems = *itemAlloc;
// will the new entries fit?
emptyItems = allocItems - numItems;
if (newItems > emptyItems)
{
// allocate the number of entries needed or the hint, whichever is
more
allocItems = numItems + newItems;
if (itemHint > allocItems)
{
allocItems = itemHint;
}
rcAlloc = realloc(items, allocItems * itemSize);
if (rcAlloc)
{
*(void**)items = rcAlloc;
This code is probably wrong. Make item a void** and get rid of the cast.
Andrew.