Sunday, 15 July 2012

c - Program exits after calling malloc -


I have a simple program that allocates memory, and copies one file from that resource to that memory space , But the problem is programmable after calling the malloc function without any exceptions or errors I use VS2010 Express, I keep a breakpoint, and when I exit the program F10 (upwards) hit here The code is:

  int main NY) {Acarsarsi Arinfo; HGLOBAL rPointer; PVOD file indicator; Int fileSize; Unsigned char * buffer; RInfu = Search Resource (0, Mccentreras (101), RDRCDATA); If (rInfo == faucet) {return 0; } RPointer = LoadResource (NULL, rInfo); If (rpinder == faucet) {return 0; } FilePointer = LockResource (rPointer); If (filePointer == NULL) {return 0; } FileSize = SizeofResource (0, rInfo); If (fileSize == 0) {return 0; } Buffer = (unsigned char *) malloc (fileSize); // & lt; - Breakpoints here (buffer == tap) {message box A (0, "Error in allocating memory.", "My app", 0); } Other {Messbox A (0, "Allocated memory without errors.", "My app", 0); } Memcpy (buffer, stub pointer, stub size); }  

I SizeofResource (0, rInfo); (1024 bytes, by using the debugger) has been verified by the size returned by I do not know whether you want and infos. Tell me


No comments:

Post a Comment