]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/snap/util.c
9bootfat: rename open() to fileinit and make it static as its really a internal funct...
[plan9front.git] / sys / src / cmd / snap / util.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include "snap.h"
5
6 void*
7 emalloc(ulong n)
8 {
9         void *v;
10         v = malloc(n);
11         if(v == nil){
12                 fprint(2, "out of memory\n");
13                 exits("memory");
14         }
15         memset(v, 0, n);
16         return v;
17 }
18
19 void*
20 erealloc(void *v, ulong n)
21 {
22         v = realloc(v, n);
23         if(v == nil) {
24                 fprint(2, "out of memory\n");
25                 exits("memory");
26         }
27         return v;
28 }
29
30 char*
31 estrdup(char *s)
32 {
33         s = strdup(s);
34         if(s == nil) {
35                 fprint(2, "out of memory\n");
36                 exits("memory");
37         }
38         return s;
39 }