From: Fabian Keil Date: Sun, 22 May 2011 10:30:55 +0000 (+0000) Subject: Garbage collect the strdup() replacement for mingw32 X-Git-Tag: v_3_0_18~226 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=47b90119a38397c9710d7d9ff2ec316de017569d Garbage collect the strdup() replacement for mingw32 Supposedly it was added ten years ago to paper over a mingw32 bug where the returned pointer couldn't be free'd, but I doubt that the bug still exists assuming the problem was analyzed correctly in the first place. If it does, we should notice soon enough as I'd consider free'ing pointers returned by strdup() a rather common operation. --- diff --git a/miscutil.c b/miscutil.c index 421f2b5c..58f0c647 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,4 +1,4 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.65 2011/04/19 13:00:47 fabiankeil Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 1.66 2011/05/22 10:26:45 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $ @@ -159,37 +159,6 @@ unsigned int hash_string( const char* s ) } -#ifdef __MINGW32__ -/********************************************************************* - * - * Function : strdup - * - * Description : For some reason (which is beyond me), gcc and WIN32 - * don't like strdup. When a "free" is executed on a - * strdup'd ptr, it can at times freez up! So I just - * replaced it and problem was solved. - * - * Parameters : - * 1 : s = string to duplicate - * - * Returns : Pointer to newly malloc'ed copy of the string. - * - *********************************************************************/ -char *strdup( const char *s ) -{ - char * result = (char *)malloc( strlen(s)+1 ); - - if (result != NULL) - { - strcpy( result, s ); - } - - return( result ); -} - -#endif /* def __MINGW32__ */ - - /********************************************************************* * * Function : strcmpic diff --git a/miscutil.h b/miscutil.h index 4fbc5092..c1ab3e2b 100644 --- a/miscutil.h +++ b/miscutil.h @@ -1,6 +1,6 @@ #ifndef MISCUTIL_H_INCLUDED #define MISCUTIL_H_INCLUDED -#define MISCUTIL_H_VERSION "$Id: miscutil.h,v 1.31 2009/05/16 13:27:20 fabiankeil Exp $" +#define MISCUTIL_H_VERSION "$Id: miscutil.h,v 1.32 2011/05/22 10:26:45 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/miscutil.h,v $ @@ -67,10 +67,6 @@ extern char *make_path(const char * dir, const char * file); long int pick_from_range(long int range); -#ifdef __MINGW32__ -extern char *strdup(const char *s); -#endif /* def __MINGW32__ */ - #ifndef HAVE_SNPRINTF extern int snprintf(char *, size_t, const char *, /*args*/ ...); #endif /* ndef HAVE_SNPRINTF */