From: cuz Date: Wed, 14 Jun 2000 09:38:07 +0000 (+0000) Subject: Move stuff into the common directory X-Git-Tag: V2.12.0~3443 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6a482b59fa8160accdef46c2b329ec36e52a6c8f;p=cc65 Move stuff into the common directory git-svn-id: svn://svn.cc65.org/cc65/trunk@70 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ar65/exports.c b/src/ar65/exports.c index 9c1ad9d14..01d8f0ded 100644 --- a/src/ar65/exports.c +++ b/src/ar65/exports.c @@ -36,8 +36,8 @@ #include #include "../common/hashstr.h" +#include "../common/xmalloc.h" -#include "mem.h" #include "error.h" #include "objdata.h" #include "exports.h" @@ -77,7 +77,7 @@ static HashEntry* NewHashEntry (const char* Name, unsigned Module) unsigned Len = strlen (Name); /* Get memory for the struct */ - HashEntry* H = Xmalloc (sizeof (HashEntry) + Len); + HashEntry* H = xmalloc (sizeof (HashEntry) + Len); /* Initialize the fields and return it */ H->Next = 0; @@ -147,3 +147,4 @@ int ExpFind (const char* Name) + diff --git a/src/ar65/extract.c b/src/ar65/extract.c index aba4f6b34..6355fd1e1 100644 --- a/src/ar65/extract.c +++ b/src/ar65/extract.c @@ -35,7 +35,6 @@ #include -#include "mem.h" #include "error.h" #include "objfile.h" #include "library.h" diff --git a/src/ar65/fileio.c b/src/ar65/fileio.c index 696b4ff20..9cf095bb7 100644 --- a/src/ar65/fileio.c +++ b/src/ar65/fileio.c @@ -35,8 +35,9 @@ #include +#include "../common/xmalloc.h" + #include "error.h" -#include "mem.h" #include "fileio.h" @@ -139,7 +140,7 @@ char* ReadStr (FILE* F) unsigned Len = Read8 (F); /* Allocate memory and read the string itself */ - char* S = Xmalloc (Len + 1); + char* S = xmalloc (Len + 1); ReadData (F, S, Len); /* Terminate the string and return it */ diff --git a/src/ar65/library.c b/src/ar65/library.c index 6fd3e7d46..4906f57d5 100644 --- a/src/ar65/library.c +++ b/src/ar65/library.c @@ -37,13 +37,13 @@ #include #include -#include "../common/libdefs.h" -#include "../common/symdefs.h" +#include "../common/bitops.h" #include "../common/exprdefs.h" #include "../common/filepos.h" -#include "../common/bitops.h" +#include "../common/libdefs.h" +#include "../common/symdefs.h" +#include "../common/xmalloc.h" -#include "mem.h" #include "error.h" #include "global.h" #include "fileio.h" @@ -114,12 +114,12 @@ static void ReadIndexEntry (void) /* Exports */ O->ExportSize = Read16 (Lib); - O->Exports = Xmalloc (O->ExportSize); + O->Exports = xmalloc (O->ExportSize); ReadData (Lib, O->Exports, O->ExportSize); /* Imports */ O->ImportSize = Read16 (Lib); - O->Imports = Xmalloc (O->ImportSize); + O->Imports = xmalloc (O->ImportSize); ReadData (Lib, O->Imports, O->ImportSize); } @@ -223,7 +223,7 @@ void LibOpen (const char* Name, int MustExist, int NeedTemp) */ { /* Remember the name */ - LibName = StrDup (Name); + LibName = xstrdup (Name); /* Open the existing library for reading */ Lib = fopen (Name, "rb"); diff --git a/src/ar65/main.c b/src/ar65/main.c index 120190173..90b1d32c4 100644 --- a/src/ar65/main.c +++ b/src/ar65/main.c @@ -41,8 +41,6 @@ #include "../common/version.h" #include "global.h" -#include "error.h" -#include "mem.h" #include "add.h" #include "del.h" #include "list.h" diff --git a/src/ar65/make/gcc.mak b/src/ar65/make/gcc.mak index fae3bd38c..1f99cb2a0 100644 --- a/src/ar65/make/gcc.mak +++ b/src/ar65/make/gcc.mak @@ -16,7 +16,6 @@ OBJS = add.o \ library.o \ list.o \ main.o \ - mem.o \ objdata.o \ objfile.o diff --git a/src/ar65/make/watcom.mak b/src/ar65/make/watcom.mak index 7be93c97e..9af93c27c 100644 --- a/src/ar65/make/watcom.mak +++ b/src/ar65/make/watcom.mak @@ -73,7 +73,6 @@ OBJS = add.obj \ library.obj \ list.obj \ main.obj \ - mem.obj \ objdata.obj \ objfile.obj diff --git a/src/ar65/mem.c b/src/ar65/mem.c deleted file mode 100644 index 7d5d175c7..000000000 --- a/src/ar65/mem.c +++ /dev/null @@ -1,84 +0,0 @@ -/*****************************************************************************/ -/* */ -/* mem.c */ -/* */ -/* Memory allocation for the ar65 archiver */ -/* */ -/* */ -/* */ -/* (C) 1998 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ -/* */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - - - -#include -#include - -#include "error.h" -#include "mem.h" - - - -/*****************************************************************************/ -/* code */ -/*****************************************************************************/ - - - -void* Xmalloc (size_t size) -/* Allocate memory, check for out of memory condition. Do some debugging */ -{ - void* p; - - p = malloc (size); - if (p == 0 && size != 0) { - Error ("Out of memory"); - } - - /* Return a pointer to the block */ - return p; -} - - - -void Xfree (const void* block) -/* Free the block, do some debugging */ -{ - free ((void*) block); -} - - - -char* StrDup (const char* s) -/* Duplicate a string on the heap. The function checks for out of memory */ -{ - unsigned len; - - len = strlen (s) + 1; - return memcpy (Xmalloc (len), s, len); -} - - - diff --git a/src/ar65/mem.h b/src/ar65/mem.h deleted file mode 100644 index a896131d4..000000000 --- a/src/ar65/mem.h +++ /dev/null @@ -1,67 +0,0 @@ -/*****************************************************************************/ -/* */ -/* mem.h */ -/* */ -/* Memory allocation for the ar65 archiver */ -/* */ -/* */ -/* */ -/* (C) 1998 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ -/* */ -/* */ -/* This software is provided 'as-is', without any expressed or implied */ -/* warranty. In no event will the authors be held liable for any damages */ -/* arising from the use of this software. */ -/* */ -/* Permission is granted to anyone to use this software for any purpose, */ -/* including commercial applications, and to alter it and redistribute it */ -/* freely, subject to the following restrictions: */ -/* */ -/* 1. The origin of this software must not be misrepresented; you must not */ -/* claim that you wrote the original software. If you use this software */ -/* in a product, an acknowledgment in the product documentation would be */ -/* appreciated but is not required. */ -/* 2. Altered source versions must be plainly marked as such, and must not */ -/* be misrepresented as being the original software. */ -/* 3. This notice may not be removed or altered from any source */ -/* distribution. */ -/* */ -/*****************************************************************************/ - - - -#ifndef MEM_H -#define MEM_H - - - -#include - - - -/*****************************************************************************/ -/* Code */ -/*****************************************************************************/ - - - -void* Xmalloc (size_t size); -/* Allocate memory, check for out of memory condition. Do some debugging */ - -void Xfree (const void* block); -/* Free the block, do some debugging */ - -char* StrDup (const char* s); -/* Duplicate a string on the heap. The function checks for out of memory */ - - - -/* End of mem.h */ - -#endif - - - diff --git a/src/ar65/objdata.c b/src/ar65/objdata.c index 0fd32d362..c2d830f8e 100644 --- a/src/ar65/objdata.c +++ b/src/ar65/objdata.c @@ -35,7 +35,8 @@ #include -#include "mem.h" +#include "../common/xmalloc.h" + #include "error.h" #include "objdata.h" @@ -65,7 +66,7 @@ ObjData* NewObjData (void) /* Allocate a new structure on the heap, insert it into the list, return it */ { /* Allocate memory */ - ObjData* O = Xmalloc (sizeof (ObjData)); + ObjData* O = xmalloc (sizeof (ObjData)); /* Initialize the data */ O->Next = 0; @@ -101,10 +102,10 @@ ObjData* NewObjData (void) void FreeObjData (ObjData* O) /* Free a complete struct */ { - Xfree (O->Name); - Xfree (O->Imports); - Xfree (O->Exports); - Xfree (O); + xfree (O->Name); + xfree (O->Imports); + xfree (O->Exports); + xfree (O); } @@ -170,7 +171,7 @@ void MakeObjPool (void) unsigned Index; /* Allocate memory for the pool */ - ObjPool = Xmalloc (ObjCount * sizeof (ObjData*)); + ObjPool = xmalloc (ObjCount * sizeof (ObjData*)); /* Setup the pointers and index the objects */ Index = 0; diff --git a/src/ar65/objfile.c b/src/ar65/objfile.c index f24825098..93fcfbf42 100644 --- a/src/ar65/objfile.c +++ b/src/ar65/objfile.c @@ -45,8 +45,9 @@ #include #include +#include "../common/xmalloc.h" + #include "error.h" -#include "mem.h" #include "objdata.h" #include "fileio.h" #include "library.h" @@ -59,7 +60,7 @@ /*****************************************************************************/ - + static const char* GetModule (const char* Name) /* Get a module name from the file name */ { @@ -170,13 +171,13 @@ void ObjAdd (const char* Name) } /* Initialize the object module data structure */ - O->Name = StrDup (Module); + O->Name = xstrdup (Module); O->Flags = OBJ_HAVEDATA; O->MTime = StatBuf.st_mtime; O->ImportSize = H.ImportSize; - O->Imports = Xmalloc (O->ImportSize); + O->Imports = xmalloc (O->ImportSize); O->ExportSize = H.ExportSize; - O->Exports = Xmalloc (O->ExportSize); + O->Exports = xmalloc (O->ExportSize); /* Read imports and exports */ fseek (Obj, H.ImportOffs, SEEK_SET);