Wireshark-dev: Re: [Wireshark-dev] strlen() and NULL pointer checks
From: Gerald Combs <[email protected]>
Date: Mon, 16 May 2011 13:53:48 -0700
On 5/16/11 1:47 PM, Chris Maynard wrote:
> Jeff Morriss <[email protected]> writes:
> 
>> Is there a better way?  Or better yet, a proper solution?
> 
> Not claiming this is better or proper, just another alternative:
> 
> epan/strutil.c:
> 
> #include <string.h>
> size_t ws_strlen(const char *s)
> {
>     if (s == NULL)
>         return 0;
>     return strlen(s);
> }

or even:

guint ws_strlen(const char *s)
{
    if (s == NULL)
        return 0;
    return (guint) strlen(s);
}

We cast strlen to int and guint a *lot*.

-- 
Join us for Sharkfest ’11! · Wireshark® Developer and User Conference
Stanford University, June 13-16 · http://sharkfest.wireshark.org