Commit 79a702f4 authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl

remove Alloc and Free, use malloc and free in backend

parent 63bf8e68
......@@ -51,12 +51,12 @@ static void *AllocLarge (SizeT size)
char **newblock;
size = ReSize (size);
if ((newblock = (char **) Alloc ((unsigned long) size + SizeOf (char *), SizeOf (char)))!=NULL){
if ((newblock = (char **) malloc ((unsigned long) size + SizeOf (char *)))!=NULL){
*newblock = FirstBlock;
FirstBlock = (char *) newblock++;
NrOfBytes += size;
return (char *) newblock;
} else {
} else {
FatalCompError ("comsupport", "AllocLarge", "Insufficient Memory");
return (void *) Null;
......@@ -70,7 +70,7 @@ void InitStorage (void)
if (InitStorageFlag){
char **newblock;
if ((newblock = (char **) Alloc ((unsigned long) (MemBlockSize + (SizeT) (SizeOf (char *))), SizeOf (char)))!=NULL){
if ((newblock = (char **) malloc ((unsigned long) (MemBlockSize + (SizeT) (SizeOf (char *)))))!=NULL){
*newblock = (char *) NIL;
StartStorage = LastBlock = FirstBlock = (char *) newblock;
NextFreeMem = SizeOf(char*)+(char*)newblock;
......@@ -124,9 +124,7 @@ void *CompAlloc (SizeT size)
if (new_block-LastBlock+size > MemBlockSize+SizeOf(char*)){
char **newblock;
newblock = (char **) Alloc ((unsigned long)
(MemBlockSize + (SizeT) (sizeof (char *))), SizeOf (char));
newblock = (char **) malloc ((unsigned long)(MemBlockSize + (SizeT) (sizeof (char *))));
if (newblock!=NULL){
*((char **) LastBlock) = (char *) newblock;
LastBlock = (char *) newblock;
......@@ -172,7 +170,7 @@ void CompFree (void)
char *next_block;
next_block=*((char **) block);
Free (block);
free (block);
block=next_block;
}
......
......@@ -249,7 +249,7 @@ static void NewBlock (void)
}
}
if (! (free_pos = (char *) Alloc (BLOCK_SIZE, SizeOf (char))))
if (! (free_pos = (char *) malloc (BLOCK_SIZE)))
return;
SA_store[n_allocated_blocks] = free_pos;
......@@ -326,7 +326,7 @@ void free_unused_sa_blocks (void)
for (i=usedblocks; i<n_allocated_blocks; ++i){
if (SA_store[i]!=NULL){
Free ((void *) SA_store[i]);
free ((void *) SA_store[i]);
SA_store[i]=NULL;
}
}
......@@ -355,7 +355,7 @@ static void FreeBlocks (void)
for (i = 0; i < n_allocated_blocks; i++){
if (SA_store[i]!=NULL){
Free ((void *) SA_store[i]);
free ((void *) SA_store[i]);
SA_store[i]=NULL;
}
}
......
......@@ -39,8 +39,4 @@ extern int FPutS (char *s, File f);
extern void DoFatalError (char *s);
extern void CmdError (char *errormsg1,char *errormsg2);
extern void *Alloc (unsigned long count, SizeT size);
extern void Free (void *p);
#define ReSize(A) (((A)+3) & ~3)
......@@ -58,24 +58,3 @@ void CmdError (char *errormsg1,char *errormsg2)
fputs (errormsg2, stdout);
fputc ('\n', stdout);
}
/*******************************************************************************
* Storage *
******************************************************************************/
void *Alloc (long unsigned count, SizeT size)
{
if (size == 1)
{ if (count >= MAXUNSIGNED)
DoFatalError ("Allocate: severe memory allocation problem");
return (void *) malloc ((size_t) count);
}
else if (count >= (MAXUNSIGNED / size))
DoFatalError ("Allocate: severe memory allocation problem");
return (void *) malloc ((size_t) (count * size));
} /* Alloc */
void Free (void *p)
{
(void) free (p);
} /* Free */
......@@ -54,20 +54,3 @@ void CmdError (char *errormsg1,char *errormsg2)
fputs (errormsg2, stdout);
fputc ('\n', stdout);
}
void *Alloc (long unsigned count, SizeT size)
{
if (size == 1){
if (count >= MAXUNSIGNED)
DoFatalError ("Allocate: severe memory allocation problem");
return (void *) malloc ((size_t) count);
}
else if (count >= (MAXUNSIGNED / size))
DoFatalError ("Allocate: severe memory allocation problem");
return (void *) malloc ((size_t) (count * size));
}
void Free (void *p)
{
(void) free (p);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment