From 116860bb66f745c6678f3acf010d290f4da2775f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 10 Jun 2005 05:16:20 +0000 Subject: [PATCH] don't segfault when running out of globals --- tools/qfcc/source/def.c | 7 ++++++- tools/qfcc/source/qfcc.c | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index c7f7f9b2f..870f6975f 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -362,8 +362,13 @@ new_location (type_t *type, defspace_t *space) } ofs = space->size; space->size += size; - if (space->size > space->max_size) + if (space->size > space->max_size) { + if (!space->grow) { + error (0, "unable to allocate %d globals", size); + exit (1); + } space->grow (space); + } return ofs; } diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 99bf735b4..0ca1359c6 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -154,6 +154,8 @@ InitData (void) pr.near_data = new_defspace (); pr.near_data->data = calloc (65536, sizeof (pr_type_t)); + pr.near_data->max_size = 65536; + pr.near_data->grow = 0; pr.scope = new_scope (sc_global, pr.near_data, 0); current_scope = pr.scope;