From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- fonts/utilities/mff-29/strdup.c | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 fonts/utilities/mff-29/strdup.c (limited to 'fonts/utilities/mff-29/strdup.c') diff --git a/fonts/utilities/mff-29/strdup.c b/fonts/utilities/mff-29/strdup.c new file mode 100644 index 0000000000..784c762ace --- /dev/null +++ b/fonts/utilities/mff-29/strdup.c @@ -0,0 +1,68 @@ +/* strdup.c 2.9.0 92/07/06 - a coupla convenience routines */ + +/* - Damian Cugley Fri. 1 Mar. 1991 +----------------------------------------------------------------------- + This software module copyright (c) 1991 Damian Cugley. + It is provided for free on an "as-is" basis. + See the file COPYING for more information. +----------------------------------------------------------------------- +*/ + +#include "fatal.h" +#include "strmisc.h" + +addr malloc ARGS((sizeof_t)); +addr realloc ARGS((addr, sizeof_t)); + +#ifndef xpg2 +void +xfree(a) + addr a; +{ + int free ARGS((addr)); + + if (!free(a)) + pfatalf("free(0x%lX)", (long)a); +} +#endif + +addr malloc ARGS((sizeof_t)); +addr realloc ARGS((addr, sizeof_t)); + +addr +xmalloc(siz) + sizeof_t siz; +{ + register addr t; + + if (!(t = malloc(siz))) + pfatalf("malloc(%ld)", (long)siz); + return t; +} + +addr +xrealloc(oldptr, siz) + addr oldptr; + sizeof_t siz; +{ + register addr t; + + if (!(t = realloc(oldptr, siz))) + pfatalf("realloc(*,%ld)", (long)siz); + return t; +} + +char * +strdup(s) + const char *s; +{ + int siz; char *t; + + if (!s) return (char *)0; + siz = strlen(s) + 1; + if (!(t = malloc(siz))) + pfatalf("malloc(%ld)", (long)siz); + bcopy((addr)s, t, siz); + t[siz - 1] = 0; + return t; +} -- cgit v1.2.3