aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard>2002-08-18 13:19:18 +0000
committerbellard <bellard>2002-08-18 13:19:18 +0000
commit4891761bc9dc594b94cdbcb88f8a2dbd03b4d9b7 (patch)
tree290271eb6f6a670761308a2248a4a0be76b14871
parentacba7d10a28ef8ff2b65b48687ec5b128794bc15 (diff)
downloadtinycc-4891761bc9dc594b94cdbcb88f8a2dbd03b4d9b7.tar.gz
tinycc-4891761bc9dc594b94cdbcb88f8a2dbd03b4d9b7.tar.bz2
realloc text section in code generation
-rw-r--r--i386-gen.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/i386-gen.c b/i386-gen.c
index 8d28c27..85f101b 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -83,10 +83,15 @@ static unsigned long func_sub_sp_offset;
static unsigned long func_bound_offset;
static int func_ret_sub;
+/* XXX: make it faster ? */
void g(int c)
{
+ int ind1;
+ ind1 = ind + 1;
+ if (ind1 > cur_text_section->data_allocated)
+ section_realloc(cur_text_section, ind1);
cur_text_section->data[ind] = c;
- ind++;
+ ind = ind1;
}
void o(int c)
@@ -129,10 +134,15 @@ void gsym(int t)
/* instruction + 4 bytes data. Return the address of the data */
int oad(int c, int s)
{
+ int ind1;
+
o(c);
+ ind1 = ind + 4;
+ if (ind1 > cur_text_section->data_allocated)
+ section_realloc(cur_text_section, ind1);
*(int *)(cur_text_section->data + ind) = s;
s = ind;
- ind = ind + 4;
+ ind = ind1;
return s;
}