From: Arnaud Giersch Date: Wed, 13 Jun 2012 16:34:42 +0000 (+0200) Subject: [trace] new function: PJ_value_get_or_new(). X-Git-Tag: v3_8~625 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/696369a34c85f78ffaa5aba69fde1e5446e5d8cb [trace] new function: PJ_value_get_or_new(). --- diff --git a/src/instr/instr_paje_values.c b/src/instr/instr_paje_values.c index 488468b204..b6f1e60d14 100644 --- a/src/instr/instr_paje_values.c +++ b/src/instr/instr_paje_values.c @@ -30,6 +30,19 @@ val_t PJ_value_new (const char *name, const char *color, type_t father) return ret; } +val_t PJ_value_get_or_new (const char *name, const char *color, type_t father) +{ + xbt_ex_t e; + TRY { + return PJ_value_get(name, father); + } + CATCH(e) { + xbt_ex_free(e); + return PJ_value_new(name, color, father); + } + THROW_IMPOSSIBLE; +} + val_t PJ_value_get (const char *name, type_t father) { if (name == NULL || father == NULL){ diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 0bc4f9d2a8..49997e598a 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -224,6 +224,7 @@ void PJ_type_free_all (void); /* instr_paje_values.c */ val_t PJ_value_new (const char *name, const char *color, type_t father); +val_t PJ_value_get_or_new (const char *name, const char *color, type_t father); val_t PJ_value_get (const char *name, const type_t father); void PJ_value_free (val_t value);