]> git.sur5r.net Git - cc65/commitdiff
Move stuff into the common directory
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 14 Jun 2000 09:38:07 +0000 (09:38 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 14 Jun 2000 09:38:07 +0000 (09:38 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@70 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ar65/exports.c
src/ar65/extract.c
src/ar65/fileio.c
src/ar65/library.c
src/ar65/main.c
src/ar65/make/gcc.mak
src/ar65/make/watcom.mak
src/ar65/mem.c [deleted file]
src/ar65/mem.h [deleted file]
src/ar65/objdata.c
src/ar65/objfile.c

index 9c1ad9d141d721e61db5e8f7a7401ccea59a3ab6..01d8f0ded4629f39a6d658ddfdee35ade24aeb50 100644 (file)
@@ -36,8 +36,8 @@
 #include <string.h>
 
 #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)
 
 
 
+                   
index aba4f6b342d3dd875c83798f03d60dcba437d209..6355fd1e1f604fd1f88301d4bcdc91f00945868a 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <stdlib.h>
 
-#include "mem.h"
 #include "error.h"
 #include "objfile.h"
 #include "library.h"
index 696b4ff2031f48038414c6f2df53876b570c3298..9cf095bb78604dd320b2abf7707a437ee9305b33 100644 (file)
@@ -35,8 +35,9 @@
 
 #include <string.h>
 
+#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 */
index 6fd3e7d466cac912d2500193052d9c6a4ec47d6b..4906f57d544ae98780adb6600b3f076a7b03727f 100644 (file)
 #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"
@@ -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");
index 120190173264d007b5d4554ab1a25fca263c4be0..90b1d32c43a1904989c05695957bfe0aff1bdd6b 100644 (file)
@@ -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"
index fae3bd38cb86f2a537b28267d083e3c8ef4abaaa..1f99cb2a0350d09af64cbffe90efdc89b2f44c79 100644 (file)
@@ -16,7 +16,6 @@ OBJS =        add.o           \
        library.o       \
        list.o          \
        main.o          \
-       mem.o           \
        objdata.o       \
        objfile.o
 
index 7be93c97ebaab29b393b376cfdcfbce210af4c29..9af93c27cd1a3f36e192dc38b0f8b9f8382a39d4 100644 (file)
@@ -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 (file)
index 7d5d175..0000000
+++ /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 <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);
-}
-
-
-
diff --git a/src/ar65/mem.h b/src/ar65/mem.h
deleted file mode 100644 (file)
index a896131..0000000
+++ /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 <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
-
-
-
index 0fd32d362057bc6bcb751044e5b43a4cae919bc7..c2d830f8e144d340a41bd0b6a4b8198b5539935f 100644 (file)
@@ -35,7 +35,8 @@
 
 #include <string.h>
 
-#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;
index f24825098763e48800597ea8f3b3e75b599e2759..93fcfbf429a39ee86c4a4b00b5273d698a12dc37 100644 (file)
@@ -45,8 +45,9 @@
 #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"
@@ -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);