Crash by allocationg small blocks
From: Sebastien LEGUET (LEGUET_at_discussions.microsoft.com)
Date: 01/13/05
- Next message: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Previous message: George Hester: "switch(){ case arg{}} why?"
- Next in thread: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Doug Harrison [MVP]: "Re: Crash by allocationg small blocks"
- Reply: Severian: "Re: Crash by allocationg small blocks"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 Jan 2005 02:05:08 -0800
Hello,
I try to exeute this code and I have a crash during the execution. The
realloc function return NULL.
#include "stdio.h"
#include "stdlib.h"
int main()
{
char** pData = NULL;
char *pszFicDescName = NULL;
for( int i=0; i< 7000000; i++ )
{
pszFicDescName = (char*)malloc(1041);
strcpy(pszFicDescName,"Ceci est un test");
if (pData == NULL)
pData = (char**)malloc( sizeof(char*) );
pData = (char**)realloc( (void*)pData, (i+1)*sizeof(char*) );
//access violation in small-block allocator
pData[i] = pszFicDescName;
printf("Cpt = %d\n",i);
}
return(0);
} //end main
Could you tell me if you know about that problem and how can I resolved that
because I need to use standard C code.
I tried this code on VC6 and VC7 and I have the same result. I know that
there is a resolution by declaring _set_sbh_threshold(0); but it doesn't work
and I have the SP5 of VC6 so the realloc function has been corrected.
In fact if I comment the line
pData[i] = pszFicDescName;
the program is correctly executed to the end.
Thanks
Sebastien
- Next message: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Previous message: George Hester: "switch(){ case arg{}} why?"
- Next in thread: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Jochen Kalmbach: "Re: Crash by allocationg small blocks"
- Reply: Doug Harrison [MVP]: "Re: Crash by allocationg small blocks"
- Reply: Severian: "Re: Crash by allocationg small blocks"
- Messages sorted by: [ date ] [ thread ]