diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-01-03 01:52:03 +0100 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2014-01-03 01:52:03 +0100 |
commit | 1e7446e22af32d48f8db1d3e0fc067ef724282fa (patch) | |
tree | eada6b3b3bc52fe7d8fb5c33e98103a3f9c25763 | |
parent | cde36665e2e5fbd1d5be70e5ca388a5d2d2365ef (diff) | |
download | ratpoison-1e7446e22af32d48f8db1d3e0fc067ef724282fa.zip |
Tiny xmalloc/realloc/strdup cleanup.
* kill "register"
* compare pointers against NULL
* separate declarations and code
-rw-r--r-- | src/main.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -71,8 +71,10 @@ fatal (const char *msg) void * xmalloc (size_t size) { - register void *value = malloc (size); - if (value == 0) + void *value; + + value = malloc (size); + if (value == NULL) fatal ("Virtual memory exhausted"); return value; } @@ -80,8 +82,10 @@ xmalloc (size_t size) void * xrealloc (void *ptr, size_t size) { - register void *value = realloc (ptr, size); - if (value == 0) + void *value; + + value = realloc (ptr, size); + if (value == NULL) fatal ("Virtual memory exhausted"); return value; } @@ -91,7 +95,7 @@ xstrdup (const char *s) { char *value; value = strdup (s); - if (value == 0) + if (value == NULL) fatal ("Virtual memory exhausted"); return value; } |