Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] new function: PJ_value_get_or_new().
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 13 Jun 2012 16:34:42 +0000 (18:34 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 13 Jun 2012 17:17:28 +0000 (19:17 +0200)
src/instr/instr_paje_values.c
src/instr/instr_private.h

index 488468b..b6f1e60 100644 (file)
@@ -30,6 +30,19 @@ val_t PJ_value_new (const char *name, const char *color, type_t father)
   return ret;
 }
 
   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){
 val_t PJ_value_get (const char *name, type_t father)
 {
   if (name == NULL || father == NULL){
index 0bc4f9d..49997e5 100644 (file)
@@ -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);
 
 /* 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);
 
 val_t PJ_value_get (const char *name, const type_t father);
 void PJ_value_free (val_t value);