void *Hunk_AllocName (int size, char *name) { hunk_t *h; #ifdef PARANOID Hunk_Check (); #endif if (size < 0) Sys_Error ("Hunk_AllocName: bad size: %i", size); size = sizeof(hunk_t) + ((size + 15) & ~15); if (hunk_size - hunk_low_used - hunk_high_used < size) Sys_Error ("Hunk_AllocName: Not enough RAM allocated. Try using \"-mem 128\" on the ezQuake command line."); h = (hunk_t *)(hunk_base + hunk_low_used); hunk_low_used += size; Cache_FreeLow (hunk_low_used); memset (h, 0, size); h->size = size; h->sentinal = HUNK_SENTINEL; strlcpy (h->name, name, sizeof (h->name)); return (void *) (h + 1); }
/* =================== Hunk_AllocName =================== */ void *Hunk_AllocName (int size, const char *name) { hunk_t *h; #ifdef PARANOID Hunk_Check (); #endif if (size < 0) Sys_Error ("Hunk_Alloc: bad size: %i", size); size = sizeof(hunk_t) + ((size+15)&~15); if (hunk_size - hunk_low_used - hunk_high_used < size) Sys_Error ("Hunk_Alloc: failed on %i bytes",size); h = (hunk_t *)(hunk_base + hunk_low_used); hunk_low_used += size; Cache_FreeLow (hunk_low_used); memset (h, 0, size); h->size = size; h->sentinal = HUNK_SENTINAL; strncpy (h->name, name, 8); return (void *)(h+1); }
/* * =================== * Hunk_AllocName * =================== */ void * Hunk_AllocName(int size, const char *name) { hunk_t *h; #ifdef PARANOID Hunk_Check(); #endif if (size < 0) Sys_Error("%s: bad size: %i", __func__, size); size = sizeof(hunk_t) + ((size + 15) & ~15); if (hunk_size - hunk_low_used - hunk_high_used < size) { /* Sys_Error ("%s: failed on %i bytes", __func__, size); */ #ifdef _WIN32 Sys_Error("Not enough RAM allocated. Try starting using " "\"-heapsize 16000\" on the command line."); #else Sys_Error("Not enough RAM allocated. Try starting using " "\"-mem 16\" on the command line."); #endif } h = (hunk_t *)(hunk_base + hunk_low_used); hunk_low_used += size; Cache_FreeLow(hunk_low_used); memset(h, 0, size); h->size = size; h->sentinal = HUNK_SENTINAL; memset(h->name, 0, HUNK_NAMELEN); memcpy(h->name, name, qmin((int)strlen(name), HUNK_NAMELEN)); return (void *)(h + 1); }