morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

ealloc.c (628B)


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