- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello All
I'm moving some old msC++ code to Intel
With Intel, the porgram generates an _ASSERTE _CrtIsValidHeapPointer (pUserData) when running
The code in question is calling free(value)
Where value is locally defined as char *value
Presumably this implies that value has been created on the stack
So my questions are
a: should free be being called at all ?
and b: if so is there a compiler setting that will allow the Intel build to run as before?
Thankx for your help
Jim
=mjc=
.
I'm moving some old msC++ code to Intel
With Intel, the porgram generates an _ASSERTE _CrtIsValidHeapPointer (pUserData) when running
The code in question is calling free(value)
Where value is locally defined as char *value
Presumably this implies that value has been created on the stack
So my questions are
a: should free be being called at all ?
and b: if so is there a compiler setting that will allow the Intel build to run as before?
Thankx for your help
Jim
=mjc=
.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, unless I'm missing something, the issue is not how value has been declared (as a char *) but what has been assigned to it. If it has been assigned using some sort of malloc(), then it there should be a free() of it, but if it has been assigned some other way, or if free() has already been called on that location somewhere else (possibly in another function) then I would expect it to be problematic. For example, if you said
char *value;
value = "Hello World";
then you would not want to call free(value). But if you said
vaule = (char *)malloc(strlen("Hello World"));
then you should call free(value) at some point.
Is that what you're asking?
Thanks!
Dale
char *value;
value = "Hello World";
then you would not want to call free(value). But if you said
vaule = (char *)malloc(strlen("Hello World"));
then you should call free(value) at some point.
Is that what you're asking?
Thanks!
Dale
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, unless I'm missing something, the issue is not how value has been declared (as a char *) but what has been assigned to it. If it has been assigned using some sort of malloc(), then it there should be a free() of it, but if it has been assigned some other way, or if free() has already been called on that location somewhere else (possibly in another function) then I would expect it to be problematic. For example, if you said
char *value;
value = "Hello World";
then you would not want to call free(value). But if you said
vaule = (char *)malloc(strlen("Hello World"));
then you should call free(value) at some point.
Is that what you're asking?
Thanks!
Dale
char *value;
value = "Hello World";
then you would not want to call free(value). But if you said
vaule = (char *)malloc(strlen("Hello World"));
then you should call free(value) at some point.
Is that what you're asking?
Thanks!
Dale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankx Dale
You have confirmed my suspicions
There is no malloc - therefore the free is bad.
And I suspect this was not being caught by the old compiler
I comment out the statements (there were many of them) and the Assert goes away :)
Thankx again for your help
Cheers
Jim
=mjc=
.
You have confirmed my suspicions
There is no malloc - therefore the free is bad.
And I suspect this was not being caught by the old compiler
I comment out the statements (there were many of them) and the Assert goes away :)
Thankx again for your help
Cheers
Jim
=mjc=
.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page