snprintf(f_psinfo, sizeof(f_psinfo), "/proc/%li/psinfo", pid);
snprintf(f_usage, sizeof(f_usage), "/proc/%li/usage", pid);
- buffer = calloc(1, sizeof(pstatus_t));
+ buffer = scalloc(1, sizeof(pstatus_t));
read_file_contents(filename, buffer, sizeof(pstatus_t));
myStatus = (pstatus_t *)buffer;
- buffer = calloc(1, sizeof(psinfo_t));
+ buffer = scalloc(1, sizeof(psinfo_t));
read_file_contents(f_psinfo, buffer, sizeof(psinfo_t));
myInfo = (psinfo_t *)buffer;
- buffer = calloc(1, sizeof(prusage_t));
+ buffer = scalloc(1, sizeof(prusage_t));
read_file_contents(f_usage, buffer, sizeof(prusage_t));
myUsage = (prusage_t *)buffer;
pthread_mutex_unlock(&strerror_r_lock);
}
- /* #endif !HAVE_STRERROR_R */
+ /* #endif !HAVE_STRERROR_R */
#elif STRERROR_R_CHAR_P
{
buflen);
}
}
- /* #endif STRERROR_R_CHAR_P */
+ /* #endif STRERROR_R_CHAR_P */
#else
if (strerror_r(errnum, buf, buflen) != 0) {
return buf;
} /* char *sstrerror */
+void *scalloc(size_t nmemb, size_t size) {
+ void *r;
+
+ if ((r = calloc(nmemb, size)) == NULL) {
+ ERROR("Not enough memory.");
+ exit(3);
+ }
+
+ return r;
+} /* void *scalloc */
+
void *smalloc(size_t size) {
void *r;
#endif /* HAVE_HTONLL */
#if FP_LAYOUT_NEED_NOTHING
- /* Well, we need nothing.. */
- /* #endif FP_LAYOUT_NEED_NOTHING */
+/* Well, we need nothing.. */
+/* #endif FP_LAYOUT_NEED_NOTHING */
#elif FP_LAYOUT_NEED_ENDIANFLIP || FP_LAYOUT_NEED_INTSWAP
#if FP_LAYOUT_NEED_ENDIANFLIP
char *sstrdup(const char *s);
size_t sstrnlen(const char *s, size_t n);
char *sstrndup(const char *s, size_t n);
+void *scalloc(size_t nmemb, size_t size);
void *smalloc(size_t size);
char *sstrerror(int errnum, char *buf, size_t buflen);