#endif
#endif
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
/* -----------------------------------------------------------------------------
Result-checking malloc wrappers.
-------------------------------------------------------------------------- */
void *
stgCallocBytes (int n, int m, char *msg)
{
- int i;
- int sz = n * m;
- char* p = stgMallocBytes(sz, msg);
- for (i = 0; i < sz; i++) p[i] = 0;
- return p;
+ char *space;
+
+ if ((space = (char *) calloc((size_t) n, (size_t) m)) == NULL) {
+ /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
+ MallocFailHook((W_) n*m, msg); /*msg*/
+ stg_exit(EXIT_INTERNAL_ERROR);
+ }
+ return space;
}
/* To simplify changing the underlying allocator used
if (now == 0) {
time(&now);
+#if HAVE_CTIME_R
+ ctime_r(&now, nowstr);
+#else
strcpy(nowstr, ctime(&now));
- strcpy(nowstr+16,nowstr+19);
- nowstr[21] = '\0';
+#endif
+ memmove(nowstr+16,nowstr+19,7);
+ nowstr[21] = '\0'; // removes the \n
}
return nowstr;
}