]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
json_object.h:document json_object_new_string_len()
authorandy5995 <andy400-dev@yahoo.com>
Tue, 27 Nov 2018 17:35:45 +0000 (11:35 -0600)
committerandy5995 <andy400-dev@yahoo.com>
Tue, 27 Nov 2018 17:35:45 +0000 (11:35 -0600)
I also added a couple trivial, but related, suggestions.

closes #460

json_object.c
json_object.h

index 8a86bc6ea09a5e76995beb54c04b0af0961acfed..c5dd1b4c96607205a3c0b329f00fd17416d511d6 100644 (file)
@@ -1030,7 +1030,7 @@ struct json_object* json_object_new_string(const char *s)
        return jso;
 }
 
-struct json_object* json_object_new_string_len(const char *s, int len)
+struct json_object* json_object_new_string_len(const char *s, const int len)
 {
        char *dstbuf;
        struct json_object *jso = json_object_new(json_type_string);
index a026320366b369333ad4c13ef4269778667e2b42..f7acaf70c75c1b269dd8f65fcc169097aa5e8a66 100644 (file)
@@ -899,10 +899,21 @@ JSON_EXPORT int json_object_set_double(struct json_object *obj,double new_value)
  *
  * @param s the string
  * @returns a json_object of type json_type_string
+ * @see json_object_new_string_len()
  */
 JSON_EXPORT struct json_object* json_object_new_string(const char *s);
 
-JSON_EXPORT struct json_object* json_object_new_string_len(const char *s, int len);
+/** Create a new empty json_object of type json_type_string and allocate
+ * len characters for the new string.
+ *
+ * A copy of the string is made and the memory is managed by the json_object
+ *
+ * @param[in] s the string
+ * @param[in] len max length of the new string
+ * @returns a json_object of type json_type_string
+ * @see json_object_new_string()
+ */
+JSON_EXPORT struct json_object* json_object_new_string_len(const char *s, const int len);
 
 /** Get the string value of a json_object
  *