Oh my, and just posting these I found a couple of bugs!
:char *
:safe_replace(char **pptr, const char *s)
:{
: /*
: * Same data (also occurs if s == *ptr), nothing to do
: */
: if (*pptr) {
: if (s && strcmp(s, *pptr) == 0)
: return(*pptr);
: free(*pptr);
: }
:
: /*
: * free old, dup new.
: */
: *pptr = (s) ? strdup(s) : NULL;
: return(*pptr);
:}
Should call safe_strdup(), not strdup().
:char *
:safe_append(char **pptr, const char *s)
:{
: char *old;
: char *new;
:
: if ((old = *pptr) != NULL) {
: int newLen = strlen(old) + strlen(s) + 1;
: new = malloc(newLen);
: snprintf(new, newLen, "%s%s", old, s);
: free(old);
: } else {
: new = strdup(s);
: }
: *pptr = new;
: return(new);
:}
Ditto. Should call safe_strdup(), not strdup().
I probably should have cleaned the source up before posting it. I
also have a fatalmem() routine which assert(0)'s, and DBASSERT(0)
is simply assert(0)... really should be a fatalmem() call too.
Oh well. You get the picture!
-Matt
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message