From: navarrop Date: Tue, 28 Sep 2010 08:54:09 +0000 (+0000) Subject: Bring back useful functions for the bypass from before David's internship. X-Git-Tag: v3_5~554 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d03dd509a40da2d9e0038e2ca89fb40bee62ec8f Bring back useful functions for the bypass from before David's internship. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8270 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 2235a2204f..13a387bdcc 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -24,6 +24,32 @@ xbt_dict_t trace_connect_list_link_avail = NULL; xbt_dict_t trace_connect_list_bandwidth = NULL; xbt_dict_t trace_connect_list_latency = NULL; +/* This buffer is used to store the original buffer before substituting it by out own buffer. Useful for the foreach tag */ +static xbt_dynar_t surfxml_bufferstack_stack = NULL; +int surfxml_bufferstack_size = 2048; +static char *old_buff = NULL; +static void surf_parse_error(char *msg); + +void surfxml_bufferstack_push(int new) +{ + if (!new) + old_buff = surfxml_bufferstack; + else { + xbt_dynar_push(surfxml_bufferstack_stack, &surfxml_bufferstack); + surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); + } +} + +void surfxml_bufferstack_pop(int new) +{ + if (!new) + surfxml_bufferstack = old_buff; + else { + free(surfxml_bufferstack); + xbt_dynar_pop(surfxml_bufferstack_stack, &surfxml_bufferstack); + } +} + /* make sure these symbols are defined as strong ones in this file so that the linked can resolve them */ xbt_dynar_t STag_surfxml_platform_cb_list = NULL; xbt_dynar_t ETag_surfxml_platform_cb_list = NULL; @@ -293,6 +319,9 @@ static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list) static void init_data(void) { + if (!surfxml_bufferstack_stack) + surfxml_bufferstack_stack = xbt_dynar_new(sizeof(char *), NULL); + random_data_list = xbt_dict_new(); traces_set_list = xbt_dict_new(); trace_connect_list_host_avail = xbt_dict_new(); @@ -318,6 +347,7 @@ static void free_data(void) xbt_dict_free(&trace_connect_list_latency); xbt_dict_free(&traces_set_list); xbt_dict_free(&random_data_list); + xbt_dynar_free(&surfxml_bufferstack_stack); } /* Here start parse */