From 5c1f0f68cc08e733408b9727f3244530c39e5781 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 3 Mar 2013 01:03:33 +0000 Subject: [PATCH] Move */mem/mem.c -> similar/mem/mem.c --- SConstruct | 3 +- d1x-rebirth/mem/mem.c | 500 ----------------------------- {d2x-rebirth => similar}/mem/mem.c | 0 3 files changed, 1 insertion(+), 502 deletions(-) delete mode 100644 d1x-rebirth/mem/mem.c rename {d2x-rebirth => similar}/mem/mem.c (100%) diff --git a/SConstruct b/SConstruct index 4e47a9da2..905d9a5ff 100644 --- a/SConstruct +++ b/SConstruct @@ -307,6 +307,7 @@ class DXXProgram(DXXCommon): ] similar_common_sources = [os.path.join('similar', f) for f in [ 'arch/sdl/timer.c', +'mem/mem.c', ] ] class UserSettings(DXXCommon.UserSettings): @@ -546,7 +547,6 @@ class D1XProgram(DXXProgram): 'main/vclip.c', 'main/wall.c', 'main/weapon.c', -'mem/mem.c', 'misc/args.c', 'misc/hash.c', 'misc/physfsx.c', @@ -729,7 +729,6 @@ class D2XProgram(DXXProgram): 'main/vclip.c', 'main/wall.c', 'main/weapon.c', -'mem/mem.c', 'misc/args.c', 'misc/hash.c', 'misc/physfsrwops.c', diff --git a/d1x-rebirth/mem/mem.c b/d1x-rebirth/mem/mem.c deleted file mode 100644 index ba970d590..000000000 --- a/d1x-rebirth/mem/mem.c +++ /dev/null @@ -1,500 +0,0 @@ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - -/* - * - * Files for debugging memory allocator - * - * - */ - -#include -#include -#include -#include "physfsx.h" -#include "pstypes.h" -#include "dxxerror.h" -#include "args.h" -#include "console.h" - -#define MEMSTATS 0 -#define FULL_MEM_CHECKING 1 - -#if defined(FULL_MEM_CHECKING) && !defined(NDEBUG) - -#define CHECKSIZE 16 -#define CHECKBYTE 0xFC - -#define MAX_INDEX 10000 - -static void *MallocBase[MAX_INDEX]; -static unsigned int MallocSize[MAX_INDEX]; -static unsigned char Present[MAX_INDEX]; -static char * Filename[MAX_INDEX]; -static char * Varname[MAX_INDEX]; -static int LineNum[MAX_INDEX]; -static int BytesMalloced = 0; - -static int free_list[MAX_INDEX]; - -static int num_blocks = 0; - -static int Initialized = 0; - -static int LargestIndex = 0; - -int out_of_memory = 0; - -void mem_display_blocks(); - -void mem_init() -{ - int i; - - Initialized = 1; - - for (i=0; i= MAX_INDEX ) { - con_printf(CON_CRITICAL,"\nMEM_OUT_OF_SLOTS: Not enough space in mem.c to hold all the mallocs.\n" ); - con_printf(CON_CRITICAL, "\tBlock '%s' created in %s, line %d.\n", var, filename, line ); - Error( "MEM_OUT_OF_SLOTS" ); - } - - id = free_list[ num_blocks++ ]; - - if (id > LargestIndex ) LargestIndex = id; - - if (id==-1) - { - con_printf(CON_CRITICAL,"\nMEM_OUT_OF_SLOTS: Not enough space in mem.c to hold all the mallocs.\n" ); - //con_printf(CON_CRITICAL, "\tBlock '%s' created in %s, line %d.\n", Varname[id], Filename[id], LineNum[id] ); - Error( "MEM_OUT_OF_SLOTS" ); - } - - ptr = malloc( size+CHECKSIZE ); - - if (ptr==NULL) - { - out_of_memory = 1; - con_printf(CON_CRITICAL, "\nMEM_OUT_OF_MEMORY: Malloc returned NULL\n" ); - con_printf(CON_CRITICAL, "\tBlock '%s' created in %s, line %d.\n", Varname[id], Filename[id], LineNum[id] ); - Error( "MEM_OUT_OF_MEMORY" ); - } - - MallocBase[id] = ptr; - MallocSize[id] = size; - Varname[id] = var; - Filename[id] = filename; - LineNum[id] = line; - Present[id] = 1; - - pc = (char *)ptr; - - BytesMalloced += size; - - for (i=0; i LargestAddress ) LargestAddress = base+size; - - - psize = (int *)ptr; - psize--; - BytesMalloced += *psize; - - if (fill_zero) - memset( ptr, 0, size ); - - return ptr; -} - -void mem_free( void * buffer ) -{ - int * psize = (int *)buffer; - psize--; - - if (Initialized==0) - mem_init(); - -#if MEMSTATS - { - unsigned long theFreeMem = 0; - - if (sMemStatsFileInitialized) - { - theFreeMem = FreeMem(); - - fprintf(sMemStatsFile, - "\n%9u bytes free before attempting: FREE", theFreeMem); - } - } -#endif // end of ifdef memstats - - if (buffer==NULL) { - con_printf(CON_CRITICAL, "\nMEM_FREE_NULL: An attempt was made to free the null pointer.\n" ); - Warning( "MEM: Freeing the NULL pointer!" ); - Int3(); - return; - } - - BytesMalloced -= *psize; - - free( buffer ); -} - -void mem_display_blocks() -{ - if (Initialized==0) return; - -#if MEMSTATS - { - if (sMemStatsFileInitialized) - { - unsigned long theFreeMem = 0; - - theFreeMem = FreeMem(); - - fprintf(sMemStatsFile, - "\n%9u bytes free before closing MEMSTATS file.", theFreeMem); - fprintf(sMemStatsFile, "\nMemory Stats File Closed."); - fclose(sMemStatsFile); - } - } -#endif // end of ifdef memstats - - if (BytesMalloced != 0 ) { - con_printf(CON_CRITICAL, "\nMEM_LEAKAGE: %d bytes of memory have not been freed.\n", BytesMalloced ); - } - - if (GameArg.DbgShowMemInfo) { - con_printf(CON_CRITICAL, "\n\nMEMORY USAGE:\n" ); - con_printf(CON_CRITICAL, " %u Kbytes dynamic data\n", (LargestAddress-SmallestAddress+512)/1024 ); - con_printf(CON_CRITICAL, " %u Kbytes code/static data.\n", (SmallestAddress-(4*1024*1024)+512)/1024 ); - con_printf(CON_CRITICAL, " ---------------------------\n" ); - con_printf(CON_CRITICAL, " %u Kbytes required.\n", (LargestAddress-(4*1024*1024)+512)/1024 ); - } -} - -void mem_validate_heap() -{ -} - -void mem_print_all() -{ -} - -#endif diff --git a/d2x-rebirth/mem/mem.c b/similar/mem/mem.c similarity index 100% rename from d2x-rebirth/mem/mem.c rename to similar/mem/mem.c