gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated (30361fe0e -> 68615f85c)


From: gnunet
Subject: [gnunet] branch master updated (30361fe0e -> 68615f85c)
Date: Tue, 21 Apr 2020 13:28:14 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 30361fe0e make GNUNET_freez default, have GNUNET_free_nz for cases 
where that does not work
     new 5f5a1c7b4 add JSON spec'er for booleans
     new 68615f85c use nz

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/gnunet_json_lib.h | 11 +++++++++
 src/json/json_helper.c        | 54 +++++++++++++++++++++++++++++++++++++++++++
 src/util/os_priority.c        |  2 +-
 3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index f6cabd589..27996f18d 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -218,6 +218,17 @@ struct GNUNET_JSON_Specification
 GNUNET_JSON_spec_json (const char *name, json_t **jsonp);
 
 
+/**
+ * boolean.
+ *
+ * @param name name of the JSON field
+ * @param[out] b where to store the boolean found under @a name
+ */
+struct GNUNET_JSON_Specification
+GNUNET_JSON_spec_bool (const char *name,
+                       bool *b);
+
+
 /**
  * 8-bit integer.
  *
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 74a92ce9f..02bd6bfab 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -326,6 +326,60 @@ GNUNET_JSON_spec_json (const char *name,
 }
 
 
+/**
+ * Parse given JSON object to a bool.
+ *
+ * @param cls closure, NULL
+ * @param root the json object representing data
+ * @param[out] spec where to write the data
+ * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
+ */
+static int
+parse_bool (void *cls,
+            json_t *root,
+            struct GNUNET_JSON_Specification *spec)
+{
+  bool *b = spec->ptr;
+
+  if (json_true () == root)
+  {
+    *b = true;
+    return GNUNET_OK;
+  }
+  if (json_false () == root)
+  {
+    *b = false;
+    return GNUNET_OK;
+  }
+  GNUNET_break_op (0);
+  return GNUNET_SYSERR;
+}
+
+
+/**
+ * boolean.
+ *
+ * @param name name of the JSON field
+ * @param[out] b where to store the boolean found under @a name
+ */
+struct GNUNET_JSON_Specification
+GNUNET_JSON_spec_bool (const char *name,
+                       bool *b)
+{
+  struct GNUNET_JSON_Specification ret = {
+    .parser = &parse_bool,
+    .cleaner = NULL,
+    .cls = NULL,
+    .field = name,
+    .ptr = b,
+    .ptr_size = sizeof(bool),
+    .size_ptr = NULL
+  };
+
+  return ret;
+}
+
+
 /**
  * Parse given JSON object to a uint8_t.
  *
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 36f0d8e30..5799d893b 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -875,7 +875,7 @@ GNUNET_OS_start_process_s (int pipe_control,
                                     binary_path,
                                     argv);
   while (argv_size > 0)
-    GNUNET_free (argv[--argv_size]);
+    GNUNET_free_nz (argv[--argv_size]);
   GNUNET_free (argv);
   return proc;
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]