memory.c 1.6 KB

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