pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools
Log | Files | Refs | README | LICENSE

ealloc.c (583B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "pkg.h"
      3 
      4 void *
      5 ecalloc(size_t nmemb, size_t size)
      6 {
      7 	void *p;
      8 
      9 	p = calloc(nmemb, size);
     10 	if (!p)
     11 		eprintf("calloc: out of memory\n");
     12 	return p;
     13 }
     14 
     15 void *
     16 emalloc(size_t size)
     17 {
     18 	void *p;
     19 
     20 	p = malloc(size);
     21 	if (!p)
     22 		eprintf("malloc: out of memory\n");
     23 	return p;
     24 }
     25 
     26 void *
     27 erealloc(void *p, size_t size)
     28 {
     29 	p = realloc(p, size);
     30 	if (!p)
     31 		eprintf("realloc: out of memory\n");
     32 	return p;
     33 }
     34 
     35 char *
     36 estrdup(const char *s)
     37 {
     38 	char *p;
     39 
     40 	p = strdup(s);
     41 	if (!p)
     42 		eprintf("strdup: out of memory\n");
     43 	return p;
     44 }