X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=miscutil.c;h=58f0c647e621df5763b12679d9716f37a3d0dfda;hp=63ffca6a6b611b2837e2179b10b5795391fe1ef1;hb=fdf5690ceaae553e05cd4a71bc2ae4a55db4d3e3;hpb=1b2cc4af84a3bc3ba01ba913ca30012c9efa31d8 diff --git a/miscutil.c b/miscutil.c index 63ffca6a..58f0c647 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,16 +1,15 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.64 2009/05/19 17:45:31 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 $ * - * Purpose : zalloc, hash_string, safe_strerror, strcmpic, - * strncmpic, chomp, and MinGW32 strdup - * functions. - * These are each too small to deserve their own file - * but don't really fit in any other file. + * Purpose : zalloc, hash_string, strcmpic, strncmpic, and + * MinGW32 strdup functions. These are each too small + * to deserve their own file but don't really fit in + * any other file. * - * Copyright : Written by and Copyright (C) 2001-2007 - * the SourceForge Privoxy team. http://www.privoxy.org/ + * Copyright : Written by and Copyright (C) 2001-2011 the + * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written * by and Copyright (C) 1997 Anonymous Coders and @@ -160,75 +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 : safe_strerror - * - * Description : Variant of the library routine strerror() which will - * work on systems without the library routine, and - * which should never return NULL. - * - * Parameters : - * 1 : err = the `errno' of the last operation. - * - * Returns : An "English" string of the last `errno'. Allocated - * with strdup(), so caller frees. May be NULL if the - * system is out of memory. - * - *********************************************************************/ -char *safe_strerror(int err) -{ - char *s = NULL; - char buf[BUFFER_SIZE]; - - -#ifdef HAVE_STRERROR - s = strerror(err); -#endif /* HAVE_STRERROR */ - - if (s == NULL) - { - snprintf(buf, sizeof(buf), "(errno = %d)", err); - s = buf; - } - - return(strdup(s)); - -} - - /********************************************************************* * * Function : strcmpic