projects
/
framework
/
base
/
util-linux-ng.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Upload Tizen:Base source
[framework/base/util-linux-ng.git]
/
mount
/
xmalloc.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h> /* strdup() */
4
#include "xmalloc.h"
5
#include "nls.h" /* _() */
6
#include "sundries.h" /* EX_SYSERR */
7
8
static void
9
die_if_null(void *t) {
10
if (t == NULL)
11
die(EX_SYSERR, _("not enough memory"));
12
}
13
14
void *
15
xmalloc (size_t size) {
16
void *t;
17
18
if (size == 0)
19
return NULL;
20
21
t = malloc(size);
22
die_if_null(t);
23
24
return t;
25
}
26
27
void *
28
xrealloc (void *p, size_t size) {
29
void *t;
30
31
t = realloc(p, size);
32
die_if_null(t);
33
34
return t;
35
}
36
37
char *
38
xstrdup (const char *s) {
39
char *t;
40
41
if (s == NULL)
42
return NULL;
43
44
t = strdup(s);
45
die_if_null(t);
46
47
return t;
48
}