#define BASEDIRNAME "quake" // assumed to have a 2 or 3 following
#define PATHSEPERATOR '/'
-#ifdef SAFE_MALLOC
void *safe_malloc( size_t size ){
void *p;
return p;
}
-#endif // !SAFE_MALLOC
+
+void *safe_malloc0( size_t size ){
+ void *p;
+
+ p = calloc( 1, size );
+ if ( !p ) {
+ Error( "safe_malloc0 failed on allocation of %i bytes", size );
+ }
+
+ return p;
+}
+
+void *safe_malloc0_info( size_t size, char* info ){
+ void *p;
+
+ p = calloc( 1, size );
+ if ( !p ) {
+ Error( "%s: safe_malloc0 failed on allocation of %i bytes", info, size );
+ }
+
+ return p;
+}
// set these before calling CheckParm
int myargc;
return Q_strncasecmp( s1, s2, 99999 );
}
-// NOTE TTimo when switching to Multithread DLL (Release/Debug) in the config
-// started getting warnings about that function, prolly a duplicate with the runtime function
-// maybe we still need to have it in linux builds
-/*
- char *strupr (char *start)
- {
- char *in;
- in = start;
- while (*in)
- {
- *in = toupper(*in);
- in++;
- }
- return start;
- }
- */
-
char *strlower( char *start ){
char *in;
in = start;
if ( nBlock > 0 ) {
nAllocSize += MEM_BLOCKSIZE - nBlock;
}
- buffer = safe_malloc( nAllocSize + 1 );
- memset( buffer, 0, nAllocSize + 1 );
+ buffer = safe_malloc0( nAllocSize + 1 );
SafeRead( f, buffer, length );
fclose( f );