#include <string.h>
#include "../common/hashstr.h"
+#include "../common/xmalloc.h"
-#include "mem.h"
#include "error.h"
#include "objdata.h"
#include "exports.h"
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;
+
#include <stdlib.h>
-#include "mem.h"
#include "error.h"
#include "objfile.h"
#include "library.h"
#include <string.h>
+#include "../common/xmalloc.h"
+
#include "error.h"
-#include "mem.h"
#include "fileio.h"
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 */
#include <string.h>
#include <errno.h>
-#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"
/* 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);
}
*/
{
/* Remember the name */
- LibName = StrDup (Name);
+ LibName = xstrdup (Name);
/* Open the existing library for reading */
Lib = fopen (Name, "rb");
#include "../common/version.h"
#include "global.h"
-#include "error.h"
-#include "mem.h"
#include "add.h"
#include "del.h"
#include "list.h"
library.o \
list.o \
main.o \
- mem.o \
objdata.o \
objfile.o
library.obj \
list.obj \
main.obj \
- mem.obj \
objdata.obj \
objfile.obj
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* 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 <stdlib.h>
-#include <string.h>
-
-#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);
-}
-
-
-
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* 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 <stddef.h>
-
-
-
-/*****************************************************************************/
-/* 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
-
-
-
#include <string.h>
-#include "mem.h"
+#include "../common/xmalloc.h"
+
#include "error.h"
#include "objdata.h"
/* 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;
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);
}
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;
#include <time.h>
#include <sys/stat.h>
+#include "../common/xmalloc.h"
+
#include "error.h"
-#include "mem.h"
#include "objdata.h"
#include "fileio.h"
#include "library.h"
/*****************************************************************************/
-
+
static const char* GetModule (const char* Name)
/* Get a module name from the file 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);