From 43bb00539b8a2259e4b06120c00d8070d1114aa5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 23 Sep 2006 23:28:12 +0000 Subject: [PATCH] Remove fixed limit on size of class_decl array. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9341 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/CParse/parser.y | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/SWIG/Source/CParse/parser.y b/SWIG/Source/CParse/parser.y index b5f76b9f4..4fb063d1d 100644 --- a/SWIG/Source/CParse/parser.y +++ b/SWIG/Source/CParse/parser.y @@ -52,8 +52,9 @@ static int compact_default_args = 0; static int template_reduce = 0; static int cparse_externc = 0; +static int max_class_levels = 0; static int class_level = 0; -static Node *class_decl[16]; +static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Assist Functions @@ -3205,6 +3206,17 @@ cpp_class_decl : Delete(tpname); } } + if (class_level >= max_class_levels) { + if (!max_class_levels) { + max_class_levels = 16; + } else { + max_class_levels *= 2; + } + class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); + if (!class_decl) { + Swig_error(cparse_file, cparse_line, "realloc() failed\n"); + } + } class_decl[class_level++] = $$; inclass = 1; } cpp_members RBRACE cpp_opt_declarators { @@ -3343,6 +3355,17 @@ cpp_class_decl : } Swig_symbol_newscope(); cparse_start_line = cparse_line; + if (class_level >= max_class_levels) { + if (!max_class_levels) { + max_class_levels = 16; + } else { + max_class_levels *= 2; + } + class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); + if (!class_decl) { + Swig_error(cparse_file, cparse_line, "realloc() failed\n"); + } + } class_decl[class_level++] = $$; inclass = 1; Classprefix = NewStringEmpty();