Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Checkbox Pin
pubududilena14-Nov-04 18:45
pubududilena14-Nov-04 18:45 
GeneralRe: Checkbox Pin
ThatsAlok14-Nov-04 18:45
ThatsAlok14-Nov-04 18:45 
QuestionHow to get Driver Names of the hardisk using C++ ? Pin
pubududilena14-Nov-04 17:51
pubududilena14-Nov-04 17:51 
AnswerRe: How to get Driver Names of the hardisk using C++ ? Pin
ThatsAlok14-Nov-04 18:25
ThatsAlok14-Nov-04 18:25 
GeneralRe: How to get Driver Names of the hardisk using C++ ? Pin
pubududilena14-Nov-04 18:32
pubududilena14-Nov-04 18:32 
GeneralRe: How to get Driver Names of the hardisk using C++ ? Pin
ThatsAlok14-Nov-04 18:41
ThatsAlok14-Nov-04 18:41 
GeneralRe: How to get Driver Names of the hardisk using C++ ? Pin
Eyal Kaplan15-Nov-04 7:04
Eyal Kaplan15-Nov-04 7:04 
GeneralError: _CrtIsValidHeapPointer(pUserData) Pin
suninwater14-Nov-04 17:45
suninwater14-Nov-04 17:45 
Hi,guys:

I got a serious error when developing a DLL for my teammates' DELPHI application. Any help is appreciated.
Environment: Windows2000 AS, VC++6.0SP5.

Related code:

typedef struct _tag_MyPackage
{
int len;
char *data;
}MyPackage;

When I got some data,

MyPackage *mp = new MyPackage;
mp->data = new char[length of the data]
memcpy(mp->data, ...);
EnterCriticalSection(&m_cs);
mylist.pushback(mp);
LeaveCriticalSection(&m_cs);

When something happens, below code is executed in another thread,

EnterCriticalSection(&m_cs);

iterator = mylist.begin();
MyPackage *mp = *iterator;
memcpy(A_Pointer_Defined_Before, mp->data, mp->len);
if (mp != NULL && mp->data != NULL)
{
delete [](mp->data);
delete mp;
}
mylist.erase(iterator);

LeaveCriticalSection(&m_cs);
return;

My program runs prefectly in much time, but, in some condition it fails at this line.
delete [](mp->data);

The error message:
Program:\work\myapp\test.exe
File: dbgheap.c
Line:1044

Expression: _CrtIsValidHeapPointer(pUserData)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)


And I also found it fails only when the length of data is a bit long, say, 220000bytes. Some other short length such as 100bytes/1000bytes/50000bytes are all successfully performed.

Thanks for your patience and any replies.

GeneralLAN Pin
don7cry14-Nov-04 16:01
don7cry14-Nov-04 16:01 
GeneralRe: LAN Pin
Ryan Binns14-Nov-04 17:27
Ryan Binns14-Nov-04 17:27 
GeneralRe: LAN Pin
don7cry14-Nov-04 20:37
don7cry14-Nov-04 20:37 
GeneralRe: LAN Pin
Antony M Kancidrowski15-Nov-04 0:17
Antony M Kancidrowski15-Nov-04 0:17 
GeneralRe: LAN Pin
Anonymous15-Nov-04 1:03
Anonymous15-Nov-04 1:03 
GeneralRe: LAN Pin
Anonymous15-Nov-04 1:10
Anonymous15-Nov-04 1:10 
QuestionHow to detect the audio device is recoding? Pin
ErisonWu14-Nov-04 14:04
ErisonWu14-Nov-04 14:04 
AnswerRe: How to detect the audio device is recoding? Pin
pubududilena14-Nov-04 18:01
pubududilena14-Nov-04 18:01 
GeneralRe: How to detect the audio device is recoding? Pin
ErisonWu14-Nov-04 22:40
ErisonWu14-Nov-04 22:40 
GeneralIcons in C++ Pin
bjcee14-Nov-04 12:16
bjcee14-Nov-04 12:16 
GeneralRe: Icons in C++ Pin
bryce14-Nov-04 14:53
bryce14-Nov-04 14:53 
GeneralI'm trying to create a calculator Pin
14-Nov-04 11:23
suss14-Nov-04 11:23 
GeneralRe: I'm trying to create a calculator Pin
John R. Shaw14-Nov-04 11:41
John R. Shaw14-Nov-04 11:41 
GeneralC++ Serial I/O Comm Library Pin
CNewbie14-Nov-04 10:03
CNewbie14-Nov-04 10:03 
GeneralRe: C++ Serial I/O Comm Library Pin
John R. Shaw14-Nov-04 12:12
John R. Shaw14-Nov-04 12:12 
GeneralSimple Intro to mySQL with VS 2002 Pin
porto9914-Nov-04 8:47
porto9914-Nov-04 8:47 
GeneralMessage for ListBox - Help, please Pin
Vladimir Dubovoy14-Nov-04 7:50
Vladimir Dubovoy14-Nov-04 7:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.