Pristine Ack-5.5
[Ack-5.5.git] / util / ceg / ce_back / obj_back / memory.c
1 #include <out.h>
2 #include <system.h>
3 #include "back.h"
4 #include "hash.h"
5 #include <alloc.h>
6
7
8 /* The routines allocate more space for the segments and update the
9  * global variables. Each time the space asked for is multiplied with 2.
10  */
11
12 mem_text()
13 {
14         /* print( "text_area too small %d %d \n", text_area, text); */
15         int diff = text - text_area;
16
17         text_area = Realloc( text_area, sizeof( char) * 2 * size_text);
18         text = text_area + diff;
19         text_cnt += size_text;
20         size_text = 2 * size_text;
21 }
22
23
24 mem_data()
25 {
26         /* print( "data_area too small\n"); */
27         int diff = data - data_area;
28
29         data_area = Realloc( data_area, sizeof( char) * 2 * size_data);
30         data = data_area + diff;
31         data_cnt += size_data;
32         size_data = 2 * size_data;
33 }
34
35
36 mem_symbol_hash()
37 {
38         /* print( "symbol_table out of memory\n"); */
39
40         size_symbol = 2 * size_symbol;
41         symbol_table = (struct outname *) Realloc( (char *) symbol_table,
42                                          sizeof( struct outname) * size_symbol);
43
44         /* print( "hash out of memory\n"); */
45
46         Hashitems = (struct Hashitem *) Realloc( (char *) Hashitems,
47                                       sizeof( struct Hashitem)*(size_symbol+1));
48 }
49
50
51 mem_relo()
52 {
53         /* print( "reloc_table out of memory\n"); */
54         int diff = relo - reloc_info;
55
56         reloc_info = (struct outrelo *) Realloc( (char *) reloc_info,
57                                  sizeof( struct outrelo) * 2 * size_reloc);
58         relo = reloc_info + diff;
59         size_reloc = 2 * size_reloc;
60 }
61
62
63 mem_string()
64 {
65         int diff = string - string_area;
66
67         /* print( "string_area out of memory %d %d \n", string_area, string);*/
68
69         size_string = 2 * size_string;
70         string_area = Realloc( string_area, sizeof( char) * size_string);
71         string = string_area + diff;
72 }