[brlcad-commits] SF.net SVN: brlcad:[54725] brlcad/trunk/src/librt/namegen.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2013-03-19 04:21:07
|
Revision: 54725 http://brlcad.svn.sourceforge.net/brlcad/?rev=54725&view=rev Author: brlcad Date: 2013-03-19 04:21:01 +0000 (Tue, 19 Mar 2013) Log Message: ----------- don't see a reason for having these two formatting_style structs be on the heap. putting it on the stack takes care of the (trivial) memory leak Modified Paths: -------------- brlcad/trunk/src/librt/namegen.c Modified: brlcad/trunk/src/librt/namegen.c =================================================================== --- brlcad/trunk/src/librt/namegen.c 2013-03-19 04:18:13 UTC (rev 54724) +++ brlcad/trunk/src/librt/namegen.c 2013-03-19 04:21:01 UTC (rev 54725) @@ -129,8 +129,8 @@ static void test_regex(char *name, int style) { - struct formatting_style *standard1; - struct formatting_style *standard2; + struct formatting_style standard1 = {BU_VLS_INIT_ZERO, 0}; + struct formatting_style standard2 = {BU_VLS_INIT_ZERO, 0}; regex_t compiled_regex; regmatch_t *result_locations; @@ -139,30 +139,28 @@ int *iterators; - BU_GET(standard1, struct formatting_style); - bu_vls_init(&(standard1->regex_spec)); - bu_vls_strcat(&(standard1->regex_spec), "([rcs][.])?([^0-9^.]*)?([0-9]*)?([.][oicb])?([0-9]*)?([+u-])?([0-9]*)?"); - standard1->pos_of_type_id_char = 1; + bu_vls_init(&(standard1.regex_spec)); + bu_vls_strcat(&(standard1.regex_spec), "([rcs][.])?([^0-9^.]*)?([0-9]*)?([.][oicb])?([0-9]*)?([+u-])?([0-9]*)?"); + standard1.pos_of_type_id_char = 1; - BU_GET(standard2, struct formatting_style); - bu_vls_init(&(standard2->regex_spec)); - bu_vls_strcat(&(standard2->regex_spec), "([^0-9^.]*)?([0-9]*)?([^.]*)?([.][rcs])?([0-9]*)?([+u-])?([0-9]*)?"); - standard2->pos_of_type_id_char = 5; + bu_vls_init(&(standard2.regex_spec)); + bu_vls_strcat(&(standard2.regex_spec), "([^0-9^.]*)?([0-9]*)?([^.]*)?([.][rcs])?([0-9]*)?([+u-])?([0-9]*)?"); + standard2.pos_of_type_id_char = 5; if (style == 1) { - ret = regcomp(&compiled_regex, bu_vls_addr(&(standard1->regex_spec)), REG_EXTENDED); + ret = regcomp(&compiled_regex, bu_vls_addr(&(standard1.regex_spec)), REG_EXTENDED); if (ret != 0) { perror("regcomp"); } - components = count_format_blocks(bu_vls_addr(&(standard1->regex_spec))); + components = count_format_blocks(bu_vls_addr(&(standard1.regex_spec))); } if (style == 2) { - ret = regcomp(&compiled_regex, bu_vls_addr(&(standard2->regex_spec)), REG_EXTENDED); + ret = regcomp(&compiled_regex, bu_vls_addr(&(standard2.regex_spec)), REG_EXTENDED); if (ret != 0) { perror("regcomp"); } - components = count_format_blocks(bu_vls_addr(&(standard2->regex_spec))); + components = count_format_blocks(bu_vls_addr(&(standard2.regex_spec))); } result_locations = (regmatch_t *)bu_calloc(components + 1, sizeof(regmatch_t), "array to hold answers from regex"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |