Search the web
Sign In
New User? Sign Up
dmalloc · Debug Malloc Library (dmalloc) Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
C++ vs strdup   Message List  
Reply | Forward Message #497 of 529 |

At the top of dmalloc.h, there's a test that determines the return type
of all the wrapped functions. It ends up setting DMALLOC_PNT to void*
in the C++ case. The strdup function is supposed to always return a
char*, though. Because C++ is very picky about pointer conversion,
this can cause compiler errors because strdup is not returning a char* .
Does the following patch make sense?

--
Dan Nelson
dnelson@...


Wed Jun 18, 2003 9:49 pm

Genesys_
Offline Offline
Send Email Send Email

--- dmalloc.h.3~ Tue Jun 10 14:55:53 2003
+++ dmalloc.h.3 Wed Jun 18 16:40:38 2003
@@ -240,7 +240,7 @@
* of memory.
*/
extern
-DMALLOC_PNT dmalloc_strdup(const char *file, const int line,
+char * dmalloc_strdup(const char *file, const int line,
const char *string, const int xalloc_b);

/*


--- malloc.c.orig Tue Jun 10 14:55:53 2003
+++ malloc.c Wed Jun 18 16:45:34 2003
@@ -937,18 +937,18 @@
* xalloc_b -> If set to 1 then print an error and exit if we run out
* of memory.
*/
-DMALLOC_PNT dmalloc_strdup(const char *file, const int line,
+char * dmalloc_strdup(const char *file, const int line,
const char *string, const int xalloc_b)
{
DMALLOC_SIZE len;
- DMALLOC_PNT *new_string;
+ char *new_string;

len = strlen(string) + 1;

new_string = dmalloc_malloc(file, line, len, DMALLOC_FUNC_STRDUP,
0 /* no alignment */, xalloc_b);
if (new_string != NULL) {
- strncpy((char *)new_string, string, len - 1);
+ strncpy(new_string, string, len - 1);
new_string[len - 1] = '\0';
}



Forward
Message #497 of 529 |
Expand Messages Author Sort by Date

At the top of dmalloc.h, there's a test that determines the return type of all the wrapped functions. It ends up setting DMALLOC_PNT to void* in the C++ case....
Dan Nelson
Genesys_
Offline Send Email
Jun 18, 2003
9:49 pm

... Yes it does Dan. Like duh. Not sure why I didn't see this before. I'll push it into the main line right now. ... gray.eg3@... Copyright 2003 by...
Gray Watson
graywatson1
Offline Send Email
Jun 18, 2003
10:03 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help