I'm stocking in an implementation of a global array of structs. Now the Problem may or may not to be that this "test" only allocating ONE Element of these Array. So i Hope someone knows what I'm doing wrong. My global Target is to implement a dynamic array with dynamic size using free() and realloc
kind regards
typedef struct IntegerBuffer {
unsigned DataSize;
}IntegerBuffer;
void PrintDummy();
void AddBufferSize(size_t Size);
IntegerBuffer *SendIntBuffer = NULL;
int main()
{
AddBufferSize(3);
PrintDummy();
}
void AddBufferSize(size_t Size)
{
unsigned i;
SendIntBuffer = (IntegerBuffer*)malloc(Size*sizeof(IntegerBuffer));
for (i = 0; i < (unsigned)Size; i++)
{
SendIntBuffer[i].DataSize = i;
}
return;
}
void PrintDummy()
{
unsigned size = (sizeof(SendIntBuffer) / sizeof(SendIntBuffer[0]));
for (unsigned i = 0; i < size; i++)
{
printf("\nTestprint %i", SendIntBuffer[i].DataSize);
}
return;
}