1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

Move stuff into the common directory

git-svn-id: svn://svn.cc65.org/cc65/trunk@70 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-06-14 09:38:07 +00:00
parent 1081c1dcdd
commit 6a482b59fa
11 changed files with 27 additions and 179 deletions

View 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)

View File

@ -35,7 +35,6 @@
#include <stdlib.h>
#include "mem.h"
#include "error.h"
#include "objfile.h"
#include "library.h"

View 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 */

View File

@ -37,13 +37,13 @@
#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");

View 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"

View File

@ -16,7 +16,6 @@ OBJS = add.o \
library.o \
list.o \
main.o \
mem.o \
objdata.o \
objfile.o

View File

@ -73,7 +73,6 @@ OBJS = add.obj \
library.obj \
list.obj \
main.obj \
mem.obj \
objdata.obj \
objfile.obj

View File

@ -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);
}

View File

@ -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

View 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;

View 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);