diff options
author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-20 18:42:58 -0400 |
---|---|---|
committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-06-20 18:42:58 -0400 |
commit | 381c9c8870fad4c544f29deec22ba4be3549a731 (patch) | |
tree | f5f26e2dd380910b0ddd26e3d885d6bf56d40181 /src/memory.cpp | |
parent | 2528dc80bd1b3e6b2c09db23eb51659e30128110 (diff) |
The first of a few "CBX OCDing over code style" commits, focusing on include/* and src/* but not src/core/* or src/modules/*.
Diffstat (limited to 'src/memory.cpp')
-rw-r--r-- | src/memory.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/memory.cpp b/src/memory.cpp index 4343bf5e6..1fb1d2b21 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -7,17 +7,15 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ #include "services.h" /* smalloc, scalloc, srealloc, sstrdup: - * Versions of the memory allocation functions which will cause the - * program to terminate with an "Out of memory" error if the memory - * cannot be allocated. (Hence, the return value from these functions - * is never NULL.) + * Versions of the memory allocation functions which will cause the + * program to terminate with an "Out of memory" error if the memory + * cannot be allocated. (Hence, the return value from these functions + * is never NULL.) */ /*************************************************************************/ @@ -31,9 +29,8 @@ void *smalloc(long size) { void *buf; - if (!size) { + if (!size) size = 1; - } buf = malloc(size); if (!buf) abort(); @@ -52,9 +49,8 @@ void *scalloc(long elsize, long els) { void *buf; - if (!elsize || !els) { + if (!elsize || !els) elsize = els = 1; - } buf = calloc(elsize, els); if (!buf) abort(); @@ -73,9 +69,8 @@ void *srealloc(void *oldptr, long newsize) { void *buf; - if (!newsize) { + if (!newsize) newsize = 1; - } buf = realloc(oldptr, newsize); if (!buf) abort(); @@ -93,12 +88,15 @@ void *srealloc(void *oldptr, long newsize) char *sstrdup(const char *src) { char *ret = NULL; - if (src) { + if (src) + { ret = new char[strlen(src) + 1]; if (!ret) abort(); strcpy(ret, src); - } else { + } + else + { Alog() << "sstrdup() called with NULL-arg"; abort(); } |