Annotation of mandoc/xstd.c, Revision 1.1
1.1 ! kristaps 1: /* $Id: macro.c,v 1.5 2008/12/17 17:18:38 kristaps Exp $ */
! 2: /*
! 3: * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
! 4: *
! 5: * Permission to use, copy, modify, and distribute this software for any
! 6: * purpose with or without fee is hereby granted, provided that the
! 7: * above copyright notice and this permission notice appear in all
! 8: * copies.
! 9: *
! 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
! 11: * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
! 12: * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
! 13: * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
! 14: * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
! 15: * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
! 16: * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
! 17: * PERFORMANCE OF THIS SOFTWARE.
! 18: */
! 19: #include <err.h>
! 20: #include <stdlib.h>
! 21: #include <string.h>
! 22:
! 23: #include "private.h"
! 24:
! 25:
! 26: int
! 27: xstrcmp(const char *p1, const char *p2)
! 28: {
! 29:
! 30: return(0 == strcmp(p1, p2));
! 31: }
! 32:
! 33:
! 34: int
! 35: xstrlcat(char *dst, const char *src, size_t sz)
! 36: {
! 37:
! 38: return(strlcat(dst, src, sz) < sz);
! 39: }
! 40:
! 41:
! 42: int
! 43: xstrlcpy(char *dst, const char *src, size_t sz)
! 44: {
! 45:
! 46: return(strlcpy(dst, src, sz) < sz);
! 47: }
! 48:
! 49:
! 50:
! 51: void *
! 52: xcalloc(size_t num, size_t sz)
! 53: {
! 54: void *p;
! 55:
! 56: if (NULL == (p = calloc(num, sz)))
! 57: err(EXIT_FAILURE, "calloc");
! 58: return(p);
! 59: }
! 60:
! 61:
! 62: char *
! 63: xstrdup(const char *p)
! 64: {
! 65: char *pp;
! 66:
! 67: if (NULL == (pp = strdup(p)))
! 68: err(EXIT_FAILURE, "strdup");
! 69: return(pp);
! 70: }
! 71:
CVSweb