Extend array API
[jansson.git] / src / jansson.h
index 3aa10de..b7a75b6 100644 (file)
@@ -54,7 +54,7 @@ json_t *json_null(void);
 
 static inline json_t *json_incref(json_t *json)
 {
-    if(json)
+    if(json && json->refcount != (unsigned int)-1)
         ++json->refcount;
     return json;
 }
@@ -64,7 +64,7 @@ void json_delete(json_t *json);
 
 static inline void json_decref(json_t *json)
 {
-    if(json && --json->refcount == 0)
+    if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
         json_delete(json);
 }
 
@@ -89,6 +89,10 @@ unsigned int json_array_size(const json_t *array);
 json_t *json_array_get(const json_t *array, unsigned int index);
 int json_array_set_new(json_t *array, unsigned int index, json_t *value);
 int json_array_append_new(json_t *array, json_t *value);
+int json_array_insert_new(json_t *array, unsigned int index, json_t *value);
+int json_array_remove(json_t *array, unsigned int index);
+int json_array_clear(json_t *array);
+int json_array_extend(json_t *array, json_t *other);
 
 static inline
 int json_array_set(json_t *array, unsigned int index, json_t *value)
@@ -102,6 +106,11 @@ int json_array_append(json_t *array, json_t *value)
     return json_array_append_new(array, json_incref(value));
 }
 
+static inline
+int json_array_insert(json_t *array, unsigned int index, json_t *value)
+{
+    return json_array_insert_new(array, index, json_incref(value));
+}
 
 const char *json_string_value(const json_t *json);
 int json_integer_value(const json_t *json);
@@ -124,8 +133,8 @@ json_t *json_load_file(const char *path, json_error_t *error);
 
 #define JSON_INDENT(n)   (n & 0xFF)
 
-char *json_dumps(const json_t *json, uint32_t flags);
-int json_dumpf(const json_t *json, FILE *output, uint32_t flags);
-int json_dump_file(const json_t *json, const char *path, uint32_t flags);
+char *json_dumps(const json_t *json, unsigned long flags);
+int json_dumpf(const json_t *json, FILE *output, unsigned long flags);
+int json_dump_file(const json_t *json, const char *path, unsigned long flags);
 
 #endif