comparison lwlib/lw_alloc.c @ 21:ac311e7ffed6

Split lw_alloc.c for better linking
author lost@l-w.ca
date Sat, 22 Jan 2011 18:28:07 -0700
parents 2c24602be78f
children 8e25147c2aa8
comparison
equal deleted inserted replaced
20:f4df3bd4b85f 21:ac311e7ffed6
22 #include <stdlib.h> 22 #include <stdlib.h>
23 23
24 #define ___lw_alloc_c_seen___ 24 #define ___lw_alloc_c_seen___
25 #include "lw_alloc.h" 25 #include "lw_alloc.h"
26 26
27 void lw_free(void *P)
28 {
29 if (P)
30 free(P);
31 }
32
33 void *lw_alloc(int size) 27 void *lw_alloc(int size)
34 { 28 {
35 void *r; 29 void *r;
36 30
37 r = malloc(size); 31 r = malloc(size);
39 { 33 {
40 abort(); 34 abort();
41 } 35 }
42 return r; 36 return r;
43 } 37 }
44
45 void *lw_realloc(void *P, int S)
46 {
47 void *r;
48
49 if (!P)
50 {
51 return lw_alloc(S);
52 }
53
54 if (!S)
55 {
56 lw_free(P);
57 return NULL;
58 }
59
60 r = realloc(P, S);
61 if (!r)
62 {
63 abort();
64 }
65 return r;
66 }