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

Place shared modules into the common dir

git-svn-id: svn://svn.cc65.org/cc65/trunk@71 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-06-14 09:57:42 +00:00
parent 6a482b59fa
commit 2767f66146
17 changed files with 181 additions and 197 deletions

View File

@ -37,9 +37,10 @@
#include <string.h>
#include <errno.h>
#include "../common/xmalloc.h"
#include "global.h"
#include "error.h"
#include "mem.h"
#include "fileio.h"
#include "segments.h"
#include "exports.h"
@ -73,7 +74,7 @@ BinDesc* NewBinDesc (void)
/* Create a new binary format descriptor */
{
/* Allocate memory for a new BinDesc struct */
BinDesc* D = Xmalloc (sizeof (BinDesc));
BinDesc* D = xmalloc (sizeof (BinDesc));
/* Initialize the fields */
D->Undef = 0;
@ -89,8 +90,8 @@ BinDesc* NewBinDesc (void)
void FreeBinDesc (BinDesc* D)
/* Free a binary format descriptor */
{
Xfree (D);
}
xfree (D);
}

View File

@ -39,9 +39,9 @@
#include <errno.h>
#include "../common/bitops.h"
#include "../common/xmalloc.h"
#include "error.h"
#include "mem.h"
#include "global.h"
#include "bin.h"
#include "o65.h"
@ -125,7 +125,7 @@ static File* NewFile (const char* Name)
unsigned Len = strlen (Name);
/* Allocate memory */
File* F = Xmalloc (sizeof (File) + Len);
File* F = xmalloc (sizeof (File) + Len);
/* Initialize the fields */
F->Flags = 0;
@ -163,7 +163,7 @@ static Memory* NewMemory (const char* Name)
}
/* Allocate memory */
M = Xmalloc (sizeof (Memory) + Len);
M = xmalloc (sizeof (Memory) + Len);
/* Initialize the fields */
M->Next = 0;
@ -221,7 +221,7 @@ static SegDesc* NewSegDesc (const char* Name)
}
/* Allocate memory */
S = Xmalloc (sizeof (SegDesc) + Len);
S = xmalloc (sizeof (SegDesc) + Len);
/* Initialize the fields */
S->Next = 0;
@ -241,7 +241,7 @@ static SegDesc* NewSegDesc (const char* Name)
static void FreeSegDesc (SegDesc* S)
/* Free a segment descriptor */
{
Xfree (S);
xfree (S);
}
@ -567,7 +567,7 @@ static void MemoryInsert (Memory* M, SegDesc* S)
/* Insert the segment descriptor into the memory area list */
{
/* Create a new node for the entry */
MemListNode* N = Xmalloc (sizeof (MemListNode));
MemListNode* N = xmalloc (sizeof (MemListNode));
N->Seg = S;
N->Next = 0;

View File

@ -36,9 +36,9 @@
#include <string.h>
#include "../common/symdefs.h"
#include "../common/xmalloc.h"
#include "global.h"
#include "mem.h"
#include "error.h"
#include "fileio.h"
#include "objdata.h"
@ -73,7 +73,7 @@ static DbgSym* NewDbgSym (unsigned char Type, const char* Name, ObjData* O)
unsigned Len = strlen (Name);
/* Allocate memory */
DbgSym* D = Xmalloc (sizeof (DbgSym) + Len);
DbgSym* D = xmalloc (sizeof (DbgSym) + Len);
/* Initialize the fields */
D->Next = 0;

View File

@ -39,9 +39,9 @@
#include "../common/symdefs.h"
#include "../common/hashstr.h"
#include "../common/xmalloc.h"
#include "global.h"
#include "mem.h"
#include "error.h"
#include "fileio.h"
#include "objdata.h"
@ -88,7 +88,7 @@ static Import* NewImport (unsigned char Type, ObjData* Obj)
/* Create a new import and initialize it */
{
/* Allocate memory */
Import* I = Xmalloc (sizeof (Import));
Import* I = xmalloc (sizeof (Import));
/* Initialize the fields */
I->Next = 0;
@ -152,7 +152,7 @@ void InsertImport (Import* I)
}
/* Now free the name since it's no longer needed */
Xfree (Name);
xfree (Name);
}
@ -196,7 +196,7 @@ static Export* NewExport (unsigned char Type, const char* Name, ObjData* Obj)
unsigned Len = strlen (Name);
/* Allocate memory */
Export* E = Xmalloc (sizeof (Export) + Len);
Export* E = xmalloc (sizeof (Export) + Len);
/* Initialize the fields */
E->Next = 0;
@ -250,7 +250,7 @@ void InsertExport (Export* E)
HashTab [HashVal] = E;
}
ImpOpen -= E->ImpCount; /* Decrease open imports now */
Xfree (L);
xfree (L);
/* We must run through the import list and change the
* export pointer now.
*/
@ -493,9 +493,9 @@ static void CreateExportPool (void)
/* Allocate memory */
if (ExpPool) {
Xfree (ExpPool);
xfree (ExpPool);
}
ExpPool = Xmalloc (ExpCount * sizeof (Export*));
ExpPool = xmalloc (ExpCount * sizeof (Export*));
/* Walk through the list and insert the exports */
for (I = 0, J = 0; I < sizeof (HashTab) / sizeof (HashTab [0]); ++I) {

View File

@ -34,10 +34,10 @@
#include "../common/exprdefs.h"
#include "../common/xmalloc.h"
#include "global.h"
#include "error.h"
#include "mem.h"
#include "fileio.h"
#include "segments.h"
#include "expr.h"
@ -54,7 +54,7 @@ static ExprNode* NewExprNode (ObjData* O)
/* Create a new expression node */
{
/* Allocate fresh memory */
ExprNode* N = Xmalloc (sizeof (ExprNode));
ExprNode* N = xmalloc (sizeof (ExprNode));
N->Op = EXPR_NULL;
N->Left = 0;
N->Right = 0;
@ -70,7 +70,7 @@ static void FreeExprNode (ExprNode* E)
/* Free a node */
{
/* Free the memory */
Xfree (E);
xfree (E);
}

View File

@ -36,8 +36,8 @@
#include <string.h>
#include "../common/hashstr.h"
#include "../common/xmalloc.h"
#include "mem.h"
#include "error.h"
#include "extsyms.h"
@ -88,11 +88,11 @@ ExtSym* NewExtSym (ExtSymTab* Tab, const char* Name)
ExtSym* E = GetExtSym (Tab, Name); /* Don't care about duplicate hash here... */
if (E != 0) {
/* We do already have a symbol with this name */
Error ("Duplicate external symbol `%s'", Name);
Error ("Duplicate external symbol `%s'", Name);
}
/* Allocate memory for the structure */
E = Xmalloc (sizeof (ExtSym) + Len);
E = xmalloc (sizeof (ExtSym) + Len);
/* Initialize the structure */
E->List = 0;
@ -102,10 +102,10 @@ ExtSym* NewExtSym (ExtSymTab* Tab, const char* Name)
/* Insert the entry into the list of all symbols */
if (Tab->Last == 0) {
/* List is empty */
Tab->Root = E;
/* List is empty */
Tab->Root = E;
} else {
/* List not empty */
/* List not empty */
Tab->Last->List = E;
}
Tab->Last = E;
@ -120,13 +120,13 @@ ExtSym* NewExtSym (ExtSymTab* Tab, const char* Name)
}
static void FreeExtSym (ExtSym* E)
/* Free an external symbol structure. Will not unlink the entry, so internal
* use only.
*/
{
Xfree (E);
xfree (E);
}
@ -137,14 +137,14 @@ ExtSymTab* NewExtSymTab (void)
unsigned I;
/* Allocate memory */
ExtSymTab* Tab = Xmalloc (sizeof (ExtSymTab));
ExtSymTab* Tab = xmalloc (sizeof (ExtSymTab));
/* Initialize the fields */
Tab->Root = 0;
Tab->Last = 0;
Tab->Count = 0;
for (I = 0; I < HASHTAB_SIZE; ++I) {
Tab->HashTab [I] = 0;
Tab->HashTab [I] = 0;
}
/* Done, return the hash table */
@ -158,13 +158,13 @@ void FreeExtSymTab (ExtSymTab* Tab)
{
/* Free all entries */
while (Tab->Root) {
ExtSym* E = Tab->Root;
Tab->Root = E->Next;
FreeExtSym (E);
ExtSym* E = Tab->Root;
Tab->Root = E->Next;
FreeExtSym (E);
}
/* Free the struct itself */
Xfree (Tab);
xfree (Tab);
}

View File

@ -35,8 +35,9 @@
#include <string.h>
#include "../common/xmalloc.h"
#include "error.h"
#include "mem.h"
#include "fileio.h"
@ -232,7 +233,7 @@ char* ReadMallocedStr (FILE* F)
unsigned Len = Read8 (F);
/* Allocate memory */
char* Str = Xmalloc (Len + 1);
char* Str = xmalloc (Len + 1);
/* Read the string itself */
ReadData (F, Str, Len);
@ -267,3 +268,4 @@ void* ReadData (FILE* F, void* Data, unsigned Size)

View File

@ -43,8 +43,6 @@
const char* ProgName = "ld65"; /* Program name */
const char* OutputName = "a.out"; /* Name of output file */
unsigned long StartAddr = 0x200; /* Start address */

View File

@ -44,8 +44,6 @@
extern const char* ProgName; /* Program name */
extern const char* OutputName; /* Name of output file */
extern unsigned long StartAddr; /* Start address */

View File

@ -37,18 +37,18 @@
#include <string.h>
#include <errno.h>
#include "../common/objdefs.h"
#include "../common/libdefs.h"
#include "../common/symdefs.h"
#include "../common/exprdefs.h"
#include "../common/filepos.h"
#include "../common/libdefs.h"
#include "../common/objdefs.h"
#include "../common/symdefs.h"
#include "../common/xmalloc.h"
#include "mem.h"
#include "error.h"
#include "exports.h"
#include "fileio.h"
#include "objdata.h"
#include "objfile.h"
#include "exports.h"
#include "library.h"
@ -97,7 +97,7 @@ static void LibReadObjHeader (ObjData* O)
O->Header.ExportOffs = Read32 (Lib);
O->Header.ExportSize = Read32 (Lib);
O->Header.DbgSymOffs = Read32 (Lib);
O->Header.DbgSymSize = Read32 (Lib);
O->Header.DbgSymSize = Read32 (Lib);
}
@ -120,7 +120,7 @@ static ObjData* ReadIndexEntry (void)
/* Skip the export size, then read the exports */
Read16 (Lib);
O->ExportCount = Read16 (Lib);
O->Exports = Xmalloc (O->ExportCount * sizeof (Export*));
O->Exports = xmalloc (O->ExportCount * sizeof (Export*));
for (I = 0; I < O->ExportCount; ++I) {
O->Exports [I] = ReadExport (Lib, O);
}
@ -128,7 +128,7 @@ static ObjData* ReadIndexEntry (void)
/* Skip the import size, then read the imports */
Read16 (Lib);
O->ImportCount = Read16 (Lib);
O->Imports = Xmalloc (O->ImportCount * sizeof (Import*));
O->Imports = xmalloc (O->ImportCount * sizeof (Import*));
for (I = 0; I < O->ImportCount; ++I) {
O->Imports [I] = ReadImport (Lib, O);
}
@ -146,7 +146,7 @@ static void ReadIndex (void)
/* Read the object file count and allocate memory */
ModuleCount = Read16 (Lib);
Index = Xmalloc (ModuleCount * sizeof (ObjData*));
Index = xmalloc (ModuleCount * sizeof (ObjData*));
/* Read all entries in the index */
for (I = 0; I < ModuleCount; ++I) {
@ -204,7 +204,7 @@ void LibAdd (FILE* F, const char* Name)
/* Store the parameters, so they're visible for other routines */
Lib = F;
LibName = StrDup (Name);
LibName = xstrdup (Name);
/* Read the remaining header fields (magic is already read) */
Header.Magic = LIB_MAGIC;
@ -270,7 +270,7 @@ void LibAdd (FILE* F, const char* Name)
/* Done. Close the file, release allocated memory */
fclose (F);
Xfree (Index);
xfree (Index);
Lib = 0;
LibName = 0;
ModuleCount = 0;

View File

@ -38,13 +38,14 @@
#include <string.h>
#include <errno.h>
#include "../common/cmdline.h"
#include "../common/libdefs.h"
#include "../common/objdefs.h"
#include "../common/version.h"
#include "../common/xmalloc.h"
#include "global.h"
#include "error.h"
#include "mem.h"
#include "target.h"
#include "fileio.h"
#include "scanner.h"
@ -81,37 +82,23 @@ static void Usage (void)
{
fprintf (stderr,
"Usage: %s [options] module ...\n"
"Options are:\n"
"\t-m name\t\tCreate a map file\n"
"\t-o name\t\tName the default output file\n"
"\t-t type\t\tType of target system\n"
"\t-v\t\tVerbose mode\n"
"\t-vm\t\tVerbose map file\n"
"\t-C name\t\tUse linker config file\n"
"\t-Ln name\tCreate a VICE label file\n"
"\t-Lp\t\tMark write protected segments as such (VICE)\n"
"\t-S addr\t\tSet the default start address\n"
"\t-V\t\tPrint linker version\n",
"Short options:\n"
" -h\t\t\tHelp (this text)\n"
" -m name\t\tCreate a map file\n"
" -o name\t\tName the default output file\n"
" -t type\t\tType of target system\n"
" -v\t\t\tVerbose mode\n"
" -vm\t\t\tVerbose map file\n"
" -C name\t\tUse linker config file\n"
" -Ln name\t\tCreate a VICE label file\n"
" -Lp\t\t\tMark write protected segments as such (VICE)\n"
" -S addr\t\tSet the default start address\n"
" -V\t\t\tPrint the linker version\n"
"\n"
"Long options:\n"
" --help\t\tHelp (this text)\n"
" --version\t\tPrint the linker version\n",
ProgName);
exit (EXIT_FAILURE);
}
static void UnknownOption (const char* Arg)
/* Print an error about an unknown option. Print usage information and exit */
{
fprintf (stderr, "Unknown option: %s\n", Arg);
Usage ();
}
static void InvNumber (const char* Arg)
/* Print an error about an unknown option. Print usage information and exit */
{
fprintf (stderr, "Invalid number given in argument: %s\n", Arg);
Usage ();
}
@ -122,17 +109,20 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
*/
{
unsigned long Val;
int Converted;
/* Convert */
if (*Number == '$') {
++Number;
if (sscanf (Number, "%lx", &Val) != 1) {
InvNumber (Arg);
}
Converted = sscanf (Number, "%lx", &Val);
} else {
if (sscanf (Number, "%li", (long*)&Val) != 1) {
InvNumber (Arg);
}
Converted = sscanf (Number, "%li", (long*)&Val);
}
/* Check if we do really have a number */
if (Converted != 1) {
fprintf (stderr, "Invalid number given in argument: %s\n", Arg);
exit (EXIT_FAILURE);
}
/* Return the result */
@ -141,37 +131,6 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
static const char* GetArg (int* ArgNum, char* argv [], unsigned Len)
/* Get an option argument */
{
const char* Arg = argv [*ArgNum];
if (Arg [Len] != '\0') {
/* Argument appended */
return Arg + Len;
} else {
/* Separate argument */
Arg = argv [*ArgNum + 1];
if (Arg == 0) {
/* End of arguments */
fprintf (stderr, "Option requires an argument: %s\n", argv [*ArgNum]);
exit (EXIT_FAILURE);
}
++(*ArgNum);
return Arg;
}
}
static void LongOption (int* Arg, char* argv [])
/* Handle a long command line option */
{
/* For now ... */
UnknownOption (argv [*Arg]);
}
static int HasPath (const char* Name)
/* Check if the given Name has a path component */
{
@ -199,7 +158,7 @@ static void LinkFile (const char* Name)
* path separator character eventually needed.
*/
Len = LibPathLen;
NewName = Xmalloc (strlen (Name) + Len + 2);
NewName = xmalloc (strlen (Name) + Len + 2);
/* Build the new name */
memcpy (NewName, LibPath, Len);
if (NewName [Len-1] != '/' && NewName [Len-1] != '\\') {
@ -243,7 +202,26 @@ static void LinkFile (const char* Name)
* be freed if we run into an error, but that's no problem. Adding more
* code to work around it will use more memory than the chunk that's lost.
*/
Xfree (NewName);
xfree (NewName);
}
static void OptHelp (const char* Opt, const char* Arg)
/* Print usage information and exit */
{
Usage ();
exit (EXIT_SUCCESS);
}
static void OptVersion (const char* Opt, const char* Arg)
/* Print the assembler version */
{
fprintf (stderr,
"ld65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH);
}
@ -251,8 +229,17 @@ static void LinkFile (const char* Name)
int main (int argc, char* argv [])
/* Assembler main program */
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--help", 0, OptHelp },
{ "--version", 0, OptVersion },
};
int I;
/* Initialize the cmdline module */
InitCmdLine (argc, argv, "ld65");
/* Evaluate the CC65_LIB environment variable */
LibPath = getenv ("CC65_LIB");
if (LibPath == 0) {
@ -260,7 +247,7 @@ int main (int argc, char* argv [])
#ifdef CC65_LIB
LibPath = CC65_LIB;
#else
LibPath = "/usr/lib/cc65/lib/";
LibPath = "/usr/lib/cc65/lib/";
#endif
}
LibPathLen = strlen (LibPath);
@ -268,7 +255,7 @@ int main (int argc, char* argv [])
/* Check the parameters */
I = 1;
while (I < argc) {
/* Get the argument */
const char* Arg = argv [I];
@ -279,22 +266,22 @@ int main (int argc, char* argv [])
switch (Arg [1]) {
case '-':
LongOption (&I, argv);
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break;
case 'm':
MapFileName = GetArg (&I, argv, 2);
MapFileName = GetArg (&I, 2);
break;
case 'o':
OutputName = GetArg (&I, argv, 2);
OutputName = GetArg (&I, 2);
break;
case 't':
if (CfgAvail ()) {
Error ("Cannot use -C/-t twice");
}
TgtSet (GetArg (&I, argv, 2));
TgtSet (GetArg (&I, 2));
break;
case 'v':
@ -309,25 +296,23 @@ int main (int argc, char* argv [])
if (CfgAvail ()) {
Error ("Cannot use -C/-t twice");
}
CfgSetName (GetArg (&I, argv, 2));
CfgSetName (GetArg (&I, 2));
break;
case 'L':
switch (Arg [2]) {
case 'n': LabelFileName = GetArg (&I, argv, 3); break;
case 'p': WProtSegs = 1; break;
default: UnknownOption (Arg);
case 'n': LabelFileName = GetArg (&I, 3); break;
case 'p': WProtSegs = 1; break;
default: UnknownOption (Arg); break;
}
break;
case 'S':
StartAddr = CvtNumber (Arg, GetArg (&I, argv, 2));
StartAddr = CvtNumber (Arg, GetArg (&I, 2));
break;
case 'V':
fprintf (stderr,
"ld65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH);
OptVersion (Arg, 0);
break;
default:
@ -349,13 +334,13 @@ int main (int argc, char* argv [])
/* Check if we had any object files */
if (ObjFiles == 0) {
fprintf (stderr, "No object files to link\n");
Usage ();
exit (EXIT_FAILURE);
}
/* Check if we have a valid configuration */
if (!CfgAvail ()) {
fprintf (stderr, "Memory configuration missing\n");
Usage ();
exit (EXIT_FAILURE);
}
/* Read the config file */
@ -389,3 +374,4 @@ int main (int argc, char* argv [])

View File

@ -21,7 +21,6 @@ OBJS = bin.o \
library.o \
main.o \
mapfile.o \
mem.o \
o65.o \
objdata.o \
objfile.o \
@ -54,7 +53,7 @@ clean:
zap: clean
rm -f *.o $(EXECS) .depend
# ------------------------------------------------------------------------------
# Make the dependencies

View File

@ -76,7 +76,6 @@ OBJS = bin.obj \
library.obj \
main.obj \
mapfile.obj \
mem.obj \
o65.obj \
objdata.obj \
objfile.obj \
@ -117,7 +116,6 @@ FILE global.obj
FILE library.obj
FILE main.obj
FILE mapfile.obj
FILE mem.obj
FILE o65.obj
FILE objdata.obj
FILE objfile.obj

View File

@ -39,13 +39,13 @@
#include <time.h>
#include "../common/version.h"
#include "../common/xmalloc.h"
#include "global.h"
#include "error.h"
#include "mem.h"
#include "fileio.h"
#include "exports.h"
#include "expr.h"
#include "fileio.h"
#include "global.h"
#include "o65.h"
@ -281,12 +281,12 @@ static O65RelocTab* NewO65RelocTab (void)
/* Create a new relocation table */
{
/* Allocate a new structure */
O65RelocTab* R = Xmalloc (sizeof (O65RelocTab));
O65RelocTab* R = xmalloc (sizeof (O65RelocTab));
/* Initialize the data */
R->Size = RELOC_BLOCKSIZE;
R->Fill = 0;
R->Buf = Xmalloc (RELOC_BLOCKSIZE);
R->Buf = xmalloc (RELOC_BLOCKSIZE);
/* Return the created struct */
return R;
@ -297,8 +297,8 @@ static O65RelocTab* NewO65RelocTab (void)
static void FreeO65RelocTab (O65RelocTab* R)
/* Free a relocation table */
{
Xfree (R->Buf);
Xfree (R);
xfree (R->Buf);
xfree (R);
}
@ -309,9 +309,9 @@ static void O65RelocPutByte (O65RelocTab* R, unsigned B)
/* Do we have enough space in the buffer? */
if (R->Fill == R->Size) {
/* We need to grow the buffer */
unsigned char* NewBuf = Xmalloc (R->Size + RELOC_BLOCKSIZE);
unsigned char* NewBuf = xmalloc (R->Size + RELOC_BLOCKSIZE);
memcpy (NewBuf, R->Buf, R->Size);
Xfree (R->Buf);
xfree (R->Buf);
R->Buf = NewBuf;
}
@ -353,7 +353,7 @@ static O65Option* NewO65Option (unsigned Type, const void* Data, unsigned DataLe
CHECK (DataLen <= 253);
/* Allocate memory */
O = Xmalloc (sizeof (O65Option) - 1 + DataLen);
O = xmalloc (sizeof (O65Option) - 1 + DataLen);
/* Initialize the structure */
O->Next = 0;
@ -370,7 +370,7 @@ static O65Option* NewO65Option (unsigned Type, const void* Data, unsigned DataLe
static void FreeO65Option (O65Option* O)
/* Free an O65Option struct */
{
Xfree (O);
xfree (O);
}
@ -718,7 +718,7 @@ O65Desc* NewO65Desc (void)
/* Create, initialize and return a new O65 descriptor struct */
{
/* Allocate a new structure */
O65Desc* D = Xmalloc (sizeof (O65Desc));
O65Desc* D = xmalloc (sizeof (O65Desc));
/* Initialize the header */
D->Header.Version = 0;
@ -761,10 +761,10 @@ void FreeO65Desc (O65Desc* D)
/* Delete the descriptor struct with cleanup */
{
/* Free the segment arrays */
Xfree (D->ZPSeg);
Xfree (D->BssSeg);
Xfree (D->DataSeg);
Xfree (D->TextSeg);
xfree (D->ZPSeg);
xfree (D->BssSeg);
xfree (D->DataSeg);
xfree (D->TextSeg);
/* Free the relocation tables */
FreeO65RelocTab (D->DataReloc);
@ -782,7 +782,7 @@ void FreeO65Desc (O65Desc* D)
FreeExtSymTab (D->Imports);
/* Free the struct itself */
Xfree (D);
xfree (D);
}
@ -929,10 +929,10 @@ static void O65SetupSegments (O65Desc* D, Memory* M)
}
/* Allocate memory according to the numbers */
D->TextSeg = Xmalloc (D->TextCount * sizeof (SegDesc*));
D->DataSeg = Xmalloc (D->DataCount * sizeof (SegDesc*));
D->BssSeg = Xmalloc (D->BssCount * sizeof (SegDesc*));
D->ZPSeg = Xmalloc (D->ZPCount * sizeof (SegDesc*));
D->TextSeg = xmalloc (D->TextCount * sizeof (SegDesc*));
D->DataSeg = xmalloc (D->DataCount * sizeof (SegDesc*));
D->BssSeg = xmalloc (D->BssCount * sizeof (SegDesc*));
D->ZPSeg = xmalloc (D->ZPCount * sizeof (SegDesc*));
/* Walk again through the list and setup the segment arrays */
TextIdx = DataIdx = BssIdx = ZPIdx = 0;

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;
@ -82,11 +83,11 @@ ObjData* NewObjData (void)
/* Link it into the list */
if (ObjLast) {
ObjLast->Next = O;
ObjLast = O;
ObjLast->Next = O;
ObjLast = O;
} else {
/* First entry */
ObjRoot = ObjLast = O;
/* First entry */
ObjRoot = ObjLast = O;
}
/* One object file more now */
@ -101,11 +102,11 @@ ObjData* NewObjData (void)
void FreeObjData (ObjData* O)
/* Free a complete struct */
{
Xfree (O->Name);
Xfree (O->Imports);
Xfree (O->Exports);
Xfree (O->DbgSyms);
Xfree (O);
xfree (O->Name);
xfree (O->Imports);
xfree (O->Exports);
xfree (O->DbgSyms);
xfree (O);
}

View File

@ -38,13 +38,14 @@
#include <time.h>
#include <sys/stat.h>
#include "error.h"
#include "mem.h"
#include "objdata.h"
#include "fileio.h"
#include "segments.h"
#include "exports.h"
#include "../common/xmalloc.h"
#include "dbgsyms.h"
#include "error.h"
#include "exports.h"
#include "fileio.h"
#include "objdata.h"
#include "segments.h"
#include "objfile.h"
@ -105,7 +106,7 @@ void ObjReadFiles (FILE* F, ObjData* O)
unsigned I;
O->FileCount = Read8 (F);
O->Files = Xmalloc (O->FileCount * sizeof (char*));
O->Files = xmalloc (O->FileCount * sizeof (char*));
for (I = 0; I < O->FileCount; ++I) {
/* Skip MTime and size */
Read32 (F);
@ -123,7 +124,7 @@ void ObjReadImports (FILE* F, ObjData* O)
unsigned I;
O->ImportCount = Read16 (F);
O->Imports = Xmalloc (O->ImportCount * sizeof (Import*));
O->Imports = xmalloc (O->ImportCount * sizeof (Import*));
for (I = 0; I < O->ImportCount; ++I) {
O->Imports [I] = ReadImport (F, O);
InsertImport (O->Imports [I]);
@ -138,7 +139,7 @@ void ObjReadExports (FILE* F, ObjData* O)
unsigned I;
O->ExportCount = Read16 (F);
O->Exports = Xmalloc (O->ExportCount * sizeof (Export*));
O->Exports = xmalloc (O->ExportCount * sizeof (Export*));
for (I = 0; I < O->ExportCount; ++I) {
O->Exports [I] = ReadExport (F, O);
InsertExport (O->Exports [I]);
@ -153,7 +154,7 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
unsigned I;
O->DbgSymCount = Read16 (F);
O->DbgSyms = Xmalloc (O->DbgSymCount * sizeof (DbgSym*));
O->DbgSyms = xmalloc (O->DbgSymCount * sizeof (DbgSym*));
for (I = 0; I < O->DbgSymCount; ++I) {
O->DbgSyms [I] = ReadDbgSym (F, O);
}
@ -167,7 +168,7 @@ void ObjReadSections (FILE* F, ObjData* O)
unsigned I;
O->SectionCount = Read8 (F);
O->Sections = Xmalloc (O->SectionCount * sizeof (Section*));
O->Sections = xmalloc (O->SectionCount * sizeof (Section*));
for (I = 0; I < O->SectionCount; ++I) {
O->Sections [I] = ReadSection (F, O);
}
@ -188,7 +189,7 @@ void ObjAdd (FILE* Obj, const char* Name)
ObjReadHeader (Obj, &O->Header, Name);
/* Initialize the object module data structure */
O->Name = StrDup (GetModule (Name));
O->Name = xstrdup (GetModule (Name));
O->Flags = OBJ_HAVEDATA;
/* Read the files list from the object file */

View File

@ -37,15 +37,15 @@
#include <string.h>
#include "../common/exprdefs.h"
#include "../common/symdefs.h"
#include "../common/segdefs.h"
#include "../common/hashstr.h"
#include "../common/segdefs.h"
#include "../common/symdefs.h"
#include "../common/xmalloc.h"
#include "mem.h"
#include "global.h"
#include "error.h"
#include "fileio.h"
#include "expr.h"
#include "fileio.h"
#include "global.h"
#include "segments.h"
@ -89,7 +89,7 @@ static Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S
/* Create a new fragment and insert it into the segment S */
{
/* Allocate memory */
Fragment* F = Xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */
Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */
/* Initialize the data */
F->Next = 0;
@ -121,7 +121,7 @@ static Segment* NewSegment (const char* Name, unsigned char Type)
unsigned Len = strlen (Name);
/* Allocate memory */
Segment* S = Xmalloc (sizeof (Segment) + Len);
Segment* S = xmalloc (sizeof (Segment) + Len);
/* Initialize the fields */
S->Next = 0;
@ -155,7 +155,7 @@ static Section* NewSection (Segment* Seg, unsigned char Align, unsigned char Typ
/* Allocate memory */
Section* S = Xmalloc (sizeof (Segment));
Section* S = xmalloc (sizeof (Segment));
/* Initialize the data */
S->Next = 0;
@ -600,7 +600,7 @@ void PrintSegmentMap (FILE* F)
Segment** SegPool;
/* Allocate memory for the segment pool */
SegPool = Xmalloc (SegCount * sizeof (Segment*));
SegPool = xmalloc (SegCount * sizeof (Segment*));
/* Collect pointers to the segments */
I = 0;
@ -643,7 +643,7 @@ void PrintSegmentMap (FILE* F)
}
/* Free the segment pool */
Xfree (SegPool);
xfree (SegPool);
}