By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,479 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,479 IT Pros & Developers. It's quick & easy.

How will it new/allocate memory when a class have string-type members?

P: n/a
HI,all
I have a class named CCC which have some members of std::string
type.
I declare a class pointer like this:
CCC* ccc = new CCC( xml_input );
then I send the ccc to another module with msg_queue.
then this lead to a error on win32 platform, but it's works well
on Redhat Linux 9.0.
what's the reason?

the error info on windows as follows:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: E:\works\server\debug\configer.exe
File: dbgheap.c
Line: 1132

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)

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
zhengfish wrote:
HI,all
I have a class named CCC which have some members of std::string
type.
I declare a class pointer like this:
CCC* ccc = new CCC( xml_input );
then I send the ccc to another module with msg_queue.
then this lead to a error on win32 platform, but it's works well
on Redhat Linux 9.0.
what's the reason?

the error info on windows as follows:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: E:\works\server\debug\configer.exe
File: dbgheap.c
Line: 1132


What is "another module"? If it is in a different process then the
address within the std::string is not valid outside of the process that
allocated it. If it is in a DLL then you could have multiple instances
of the crt memory manager. An address allocated by one manager (in exe)
cannot be passed to another manager (in DLL).

--
Scott McPhillips [VC++ MVP]

Nov 22 '05 #2

P: n/a
zhengfish wrote:
HI,all
I have a class named CCC which have some members of std::string
type.
I declare a class pointer like this:
CCC* ccc = new CCC( xml_input );
then I send the ccc to another module with msg_queue.
then this lead to a error on win32 platform, but it's works well
on Redhat Linux 9.0.
what's the reason?

the error info on windows as follows:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: E:\works\server\debug\configer.exe
File: dbgheap.c
Line: 1132

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)


You should post this question on a Microsoft newsgroup since it is not
concerned with the standard language and libraries of C++ (the topic of
this group). Please see the FAQ for what is on- and off-topic here and
for some suggestions on the right place to post:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.