00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "services.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 void *smalloc(long size)
00032 {
00033 void *buf;
00034
00035 if (!size) {
00036 size = 1;
00037 }
00038 buf = malloc(size);
00039 if (!buf)
00040 #ifndef _WIN32
00041 raise(SIGUSR1);
00042 #else
00043 abort();
00044 #endif
00045 return buf;
00046 }
00047
00048
00049
00056 void *scalloc(long elsize, long els)
00057 {
00058 void *buf;
00059
00060 if (!elsize || !els) {
00061 elsize = els = 1;
00062 }
00063 buf = calloc(elsize, els);
00064 if (!buf)
00065 #ifndef _WIN32
00066 raise(SIGUSR1);
00067 #else
00068 abort();
00069 #endif
00070 return buf;
00071 }
00072
00073
00074
00081 void *srealloc(void *oldptr, long newsize)
00082 {
00083 void *buf;
00084
00085 if (!newsize) {
00086 newsize = 1;
00087 }
00088 buf = realloc(oldptr, newsize);
00089 if (!buf)
00090 #ifndef _WIN32
00091 raise(SIGUSR1);
00092 #else
00093 abort();
00094 #endif
00095 return buf;
00096 }
00097
00098
00099
00106 char *sstrdup(const char *src)
00107 {
00108 char *ret = NULL;
00109 if (src) {
00110 #ifdef __STRICT_ANSI__
00111 if ((ret = (char *) malloc(strlen(src) + 1))) {;
00112 strcpy(ret, src);
00113 }
00114 #else
00115 ret = strdup(src);
00116 #endif
00117 if (!ret)
00118 #ifndef _WIN32
00119 raise(SIGUSR1);
00120 #else
00121 abort();
00122 #endif
00123 } else {
00124 alog("sstrdup() called with NULL-arg");
00125 if (debug)
00126 do_backtrace(0);
00127 }
00128
00129 return ret;
00130 }
00131
00132
00133
00134
00135
00136
00137
00138