Lose intermediate handling (unused). Change argument parsing to work properly over multiple buffers by saving a copy of the argument (we can't just save off/len since the buffer may vanish at any point).

This commit is contained in:
Nicholas Marriott
2007-09-29 14:25:49 +00:00
parent 653ee721df
commit 1e316cfc7c
5 changed files with 84 additions and 68 deletions

View File

@ -1,4 +1,4 @@
/* $Id: xmalloc.c,v 1.2 2007-07-25 23:13:18 nicm Exp $ */
/* $Id: xmalloc.c,v 1.3 2007-09-29 14:25:49 nicm Exp $ */
/*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@ -69,6 +69,18 @@ ensure_size(void *buf, size_t *len, size_t nmemb, size_t size)
return (buf);
}
char *
xmemstrdup(const char *buf, size_t len)
{
char *s;
s = xmalloc(len + 1);
memcpy(s, buf, len);
s[len] = '\0';
return (s);
}
char *
xstrdup(const char *s)
{