I have a small, but annoying, problem here.
So here are my structures.
typedef struct tElem {
struct tElem *ptr;
int data;
} *tElemPtr;
typedef struct {
tElemPtr Act;
tElemPtr First;
} tList;
And here is the allocation. This is where the heap corruption occurs.
tElemPtr newElemPtr = (tElemPtr)malloc(sizeof(tElemPtr));
.
.
.
free(newElemPtr);
But it doesn't occur, when I use size of the actual structure.
tElemPtr newElemPtr = (tElemPtr)malloc(sizeof(struct tElem));
.
.
.
free(newElemPtr);
Could somebody please explain to me, what am I missing here?
Thank you.