Skip to content

Commit

Permalink
Bye bye xmemstrdup crap.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Marriott committed Aug 8, 2008
1 parent f449a4a commit ac25bc6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
1 change: 0 additions & 1 deletion fdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,6 @@ __dead void log_fatalx(const char *, ...);
/* xmalloc.c */
void *ensure_size(void *, size_t *, size_t, size_t);
void *ensure_for(void *, size_t *, size_t, size_t);
char *xmemstrdup(const char *, size_t);
char *xstrdup(const char *);
void *xcalloc(size_t, size_t);
void *xmalloc(size_t);
Expand Down
3 changes: 2 additions & 1 deletion mail-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ mailtime(struct mail *m, time_t *tim)
if (hdr == NULL || len == 0)
return (-1);
/* Make a copy of the header. */
s = xmemstrdup(hdr, len);
s = xmalloc(len + 1);
strlcpy(s, hdr, len + 1);

/* Skip spaces. */
ptr = s;
Expand Down
6 changes: 4 additions & 2 deletions mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ match_header(struct mail *m, const char *patt, size_t *len, int value)

if ((last = memchr(ptr, ':', *len)) != NULL) {
hdrlen = last - ptr;
hdr = xmemstrdup(ptr, hdrlen);
hdr = xmalloc(hdrlen + 1);
strlcpy(hdr, ptr, hdrlen + 1);

if (fnmatch(patt, hdr, FNM_CASEFOLD) == 0)
break;
Expand Down Expand Up @@ -433,7 +434,8 @@ find_address(char *buf, size_t len, size_t *alen)
/* Duplicate the header as a string to work on it. */
if (len == 0)
return (NULL);
hdr = xmemstrdup(buf, len);
hdr = xmalloc(len + 1);
strlcpy(hdr, buf, len + 1);

/* First, replace any sections in "s with spaces. */
ptr = hdr;
Expand Down
12 changes: 0 additions & 12 deletions xmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ 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)
{
Expand Down

0 comments on commit ac25bc6

Please sign in to comment.