Garbage collect the strdup() replacement for mingw32
authorFabian Keil <fk@fabiankeil.de>
Sun, 22 May 2011 10:30:55 +0000 (10:30 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 22 May 2011 10:30:55 +0000 (10:30 +0000)
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.

miscutil.c
miscutil.h

index 421f2b5..58f0c64 100644 (file)
@@ -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
index 4fbc509..c1ab3e2 100644 (file)
@@ -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 */