This is invariably to do with the way I am freeing memory here, can anyone tell me exactly how/why?
This could be anything, but I am hopped up on goof ballz trying to keep the flu away at the moment.. Not thinking straight!
Using MS VC++ V6.0
Windows XP
This is the error (in a popup window)Code:#include <stdio.h> #include <stdlib.h> typedef struct { void *foo; } MYSTRUCT1; typedef struct { int data; } MYSTRUCT2; int main(void) { MYSTRUCT1 *struct1; MYSTRUCT2 *struct2; struct1 = malloc (sizeof(MYSTRUCT2)); struct2 = malloc (sizeof(MYSTRUCT2)); struct1->foo = malloc (sizeof(MYSTRUCT2)); printf("Enter a number: "); scanf("%d", &struct2->data); struct1->foo = struct2; free(struct1->foo); free(struct2); free(struct1); return 0; }
Debug Assertion Failed!
Program c:\programming\foo\Debug\foo.exe
File: dbgheap.c
Line: 1017
Expression: _BLOCK_TYPE_IS_INVALID(pHead->nBlockUse)



LinkBack URL
About LinkBacks



