[PATCH] glx: Remove yet another open coded strdup()

Alan Coopersmith alan.coopersmith at oracle.com
Tue Mar 1 13:27:02 PST 2011


On 03/ 1/11 01:17 PM, Adam Jackson wrote:
> This joke is no longer funny.
> 
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  glx/glapi.c |   22 ++--------------------
>  1 files changed, 2 insertions(+), 20 deletions(-)
> 
> diff --git a/glx/glapi.c b/glx/glapi.c
> index d6a568e..fd4eb92 100644
> --- a/glx/glapi.c
> +++ b/glx/glapi.c
> @@ -226,24 +226,6 @@ PUBLIC void *_glapi_Context = NULL;
>  #endif /* defined(GLX_USE_TLS) */
>  /*@}*/
>  
> -
> -/**
> - * strdup() is actually not a standard ANSI C or POSIX routine.
> - * Irix will not define it if ANSI mode is in effect.
> - */
> -static char *
> -str_dup(const char *str)
> -{
> -   char *copy;
> -   copy = (char*) malloc(strlen(str) + 1);
> -   if (!copy)
> -      return NULL;
> -   strcpy(copy, str);
> -   return copy;
> -}
> -
> -
> -
>  /**
>   * We should call this periodically from a function such as glXMakeCurrent
>   * in order to test if multiple threads are being used.
> @@ -713,7 +695,7 @@ add_function_name( const char * funcName )
>        if (entrypoint != NULL) {
>  	 entry = & ExtEntryTable[NumExtEntryPoints];
>  
> -	 ExtEntryTable[NumExtEntryPoints].name = str_dup(funcName);
> +	 ExtEntryTable[NumExtEntryPoints].name = strdup(funcName);
>  	 ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
>  	 ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
>  	 ExtEntryTable[NumExtEntryPoints].dispatch_stub = entrypoint;
> @@ -858,7 +840,7 @@ _glapi_add_dispatch( const char * const * function_names,
>  	    }
>  	 }
>  
> -	 entry[i]->parameter_signature = str_dup(real_sig);
> +	 entry[i]->parameter_signature = strdup(real_sig);
>  	 fill_in_entrypoint_offset(entry[i]->dispatch_stub, offset);
>  	 entry[i]->dispatch_offset = offset;
>        }

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list