X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/f0efcfb7750a1c0ab3108c5a759de5c050166035..236dae9fb3183b9c1d8bc6f77614797d65800987:/xstd.c?ds=inline diff --git a/xstd.c b/xstd.c index 163a0f27..d41cb696 100644 --- a/xstd.c +++ b/xstd.c @@ -1,4 +1,4 @@ -/* $Id: xstd.c,v 1.4 2009/01/20 13:44:05 kristaps Exp $ */ +/* $Id: xstd.c,v 1.7 2009/03/06 14:13:47 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -33,6 +33,14 @@ extern size_t strlcat(char *, const char *, size_t); extern size_t strlcpy(char *, const char *, size_t); #endif + +int +xstrncmp(const char *p1, const char *p2, size_t sz) +{ + + return(0 == strncmp(p1, p2, sz)); +} + int xstrcmp(const char *p1, const char *p2) { @@ -54,6 +62,16 @@ xstrlcpy(char *dst, const char *src, size_t sz) return(strlcpy(dst, src, sz) < sz); } +void * +xrealloc(void *ptr, size_t sz) +{ + void *p; + + if (NULL == (p = realloc(ptr, sz))) + err(EXIT_FAILURE, "realloc"); + return(p); +} + void * xcalloc(size_t num, size_t sz) { @@ -75,7 +93,7 @@ xstrdup(const char *p) } int -xstrlcats(char *buf, const struct mdoc_node *n, size_t sz) +xstrlcpys(char *buf, const struct mdoc_node *n, size_t sz) { char *p;