I'm digging through the gbuffy source, in the hope of fixing various
things, and learning stuff in the process.
With my ignorance in mind, can anyone explain the point of the
safe_strdup function? What does it do that strdup doesn't? They seem
nearly identical.. Seems it would simplify things to just use strdup
instead. (similar issues come up with the geometry setting, which
currently doesn't work at all - there's an xlib function for parsing
that...)
Just for reference, here's strdup from glibc-2.3.1
char *
__strdup (const char *s)
{
size_t len = strlen (s) + 1;
void *new = malloc (len);
if (new == NULL)
return NULL;
return (char *) memcpy (new, s, len);
}
and here's safe_strdup:
char *safe_strdup (const char *s)
{
char *p;
size_t l;
if (!s || !*s) return 0;
l = strlen (s) + 1;
p = (char *)malloc (l);
memcpy (p, s, l);
return (p);
}
--
Jon-o Addleman
Curious about the PGP attachments in my e-mail?
see http://www.st-andrews.ac.uk/scotmid/pgpweb/pgpintro.shtml
to find out why they're there!