many changes, mostly for efficiency

This commit is contained in:
ceriel
1988-10-20 13:06:10 +00:00
parent a281cc38a4
commit f69a7e3e5d
18 changed files with 276 additions and 261 deletions

View File

@@ -2,8 +2,8 @@
#include <system.h>
#include "data.h"
#include "hash.h"
#include <alloc.h>
char *realloc();
/* The routines allocate more space for the segments and update the
* global variables. Each time the space asked for is multiplied with 2.
@@ -12,9 +12,11 @@ char *realloc();
mem_text()
{
/* print( "text_area too small %d %d \n", text_area, text); */
int diff = text - text_area;
text_area = realloc( text_area, sizeof( char) * 2 * size_text);
text = text_area + size_text;
text_area = Realloc( text_area, sizeof( char) * 2 * size_text);
text = text_area + diff;
_text_cnt += size_text;
size_text = 2 * size_text;
}
@@ -22,9 +24,11 @@ mem_text()
mem_data()
{
/* print( "data_area too small\n"); */
int diff = data - data_area;
data_area = realloc( data_area, sizeof( char) * 2 * size_data);
data = data_area + size_data;
data_area = Realloc( data_area, sizeof( char) * 2 * size_data);
data = data_area + diff;
_data_cnt += size_data;
size_data = 2 * size_data;
}
@@ -34,12 +38,12 @@ mem_symbol_hash()
/* print( "symbol_table out of memory\n"); */
size_symbol = 2 * size_symbol;
symbol_table = (struct outname *) realloc( (char *) symbol_table,
symbol_table = (struct outname *) Realloc( (char *) symbol_table,
sizeof( struct outname) * size_symbol);
/* print( "hash out of memory\n"); */
Hashitems = (struct Hashitem *) realloc( (char *) Hashitems,
Hashitems = (struct Hashitem *) Realloc( (char *) Hashitems,
sizeof( struct Hashitem)*(size_symbol+1));
}
@@ -47,21 +51,22 @@ mem_symbol_hash()
mem_relo()
{
/* print( "reloc_table out of memory\n"); */
int diff = relo - reloc_info;
reloc_info = (struct outrelo *) realloc( (char *) reloc_info,
reloc_info = (struct outrelo *) Realloc( (char *) reloc_info,
sizeof( struct outrelo) * 2 * size_reloc);
relo = reloc_info + size_reloc;
relo = reloc_info + diff;
size_reloc = 2 * size_reloc;
}
mem_string()
{
int i = string - string_area;
int diff = string - string_area;
/* print( "string_area out of memory %d %d \n", string_area, string);*/
size_string = 2 * size_string;
string_area = realloc( string_area, sizeof( char) * size_string);
string = string_area + i;
string_area = Realloc( string_area, sizeof( char) * size_string);
string = string_area + diff;
}