]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
rollback api to 0.12
authorHaffon <20966113@qq.com>
Thu, 7 Sep 2017 02:02:21 +0000 (10:02 +0800)
committerHaffon <20966113@qq.com>
Thu, 7 Sep 2017 02:02:21 +0000 (10:02 +0800)
arraylist.c
arraylist.h
json_object.c
json_object.h
json_pointer.c
json_tokener.c

index 3b7037fee12d94660899fd024aae128a99d5b6ad..ddeb8d4eb4ad22ad18465dc1107f3732dab965a6 100644 (file)
@@ -64,7 +64,7 @@ array_list_free(struct array_list *arr)
 }
 
 void*
-array_list_get(struct array_list *arr, size_t i)
+array_list_get_idx(struct array_list *arr, size_t i)
 {
   if(i >= arr->length) return NULL;
   return arr->array[i];
@@ -94,7 +94,7 @@ static int array_list_expand_internal(struct array_list *arr, size_t max)
 }
 
 int
-array_list_insert(struct array_list *arr, size_t idx, void *data)
+array_list_put_idx(struct array_list *arr, size_t idx, void *data)
 {
   if (idx > SIZE_T_MAX - 1 ) return -1;
   if(array_list_expand_internal(arr, idx+1)) return -1;
@@ -108,7 +108,7 @@ array_list_insert(struct array_list *arr, size_t idx, void *data)
 int
 array_list_add(struct array_list *arr, void *data)
 {
-  return array_list_insert(arr, arr->length, data);
+  return array_list_put_idx(arr, arr->length, data);
 }
 
 void
index 9519cd88293f091c27215d4055b761860a5d1029..bc10903dcc98978d8c5536f3028c5bef818dd4c2 100644 (file)
@@ -35,10 +35,10 @@ extern void
 array_list_free(struct array_list *al);
 
 extern void*
-array_list_get(struct array_list *al, size_t i);
+array_list_get_idx(struct array_list *al, size_t i);
 
 extern int
-array_list_insert(struct array_list *al, size_t i, void *data);
+array_list_put_idx(struct array_list *al, size_t i, void *data);
 
 extern int
 array_list_add(struct array_list *al, void *data);
index 5edcd7e88d682348dc61b808cb1868d27608cd3c..01ee0a87a340d57966a74b1107e68632ffd621c6 100644 (file)
@@ -161,7 +161,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, int len, int fl
 
 /* reference counting */
 
-extern struct json_object* json_object_retain(struct json_object *jso)
+extern struct json_object* json_object_get(struct json_object *jso)
 {
        if (!jso) return jso;
 
@@ -174,7 +174,7 @@ extern struct json_object* json_object_retain(struct json_object *jso)
        return jso;
 }
 
-int json_object_release(struct json_object *jso)
+int json_object_put(struct json_object *jso)
 {
        if(!jso) return 0;
 
@@ -414,7 +414,7 @@ static void json_object_lh_entry_free(struct lh_entry *ent)
 {
        if (!ent->k_is_constant)
                free(lh_entry_k(ent));
-       json_object_release((struct json_object*)lh_entry_v(ent));
+       json_object_put((struct json_object*)lh_entry_v(ent));
 }
 
 static void json_object_object_delete(struct json_object* jso)
@@ -487,7 +487,7 @@ int json_object_object_add_ex(struct json_object* jso,
        }
        existing_value = (json_object *) lh_entry_v(existing_entry);
        if (existing_value)
-               json_object_release(existing_value);
+               json_object_put(existing_value);
        existing_entry->v = val;
        return 0;
 }
@@ -1102,7 +1102,7 @@ static int json_object_array_to_json_string(struct json_object* jso,
 
 static void json_object_array_entry_free(void *data)
 {
-       json_object_release((struct json_object*)data);
+       json_object_put((struct json_object*)data);
 }
 
 static void json_object_array_delete(struct json_object* jso)
@@ -1179,7 +1179,7 @@ int json_object_array_put_idx(struct json_object *jso, size_t idx,
                              struct json_object *val)
 {
        assert(json_object_get_type(jso) == json_type_array);
-       return array_list_insert(jso->o.c_array, idx, val);
+       return array_list_put_idx(jso->o.c_array, idx, val);
 }
 
 int json_object_array_del_idx(struct json_object *jso, size_t idx, size_t count)
@@ -1192,7 +1192,7 @@ struct json_object* json_object_array_get_idx(const struct json_object *jso,
                                              size_t idx)
 {
        assert(json_object_get_type(jso) == json_type_array);
-       return (struct json_object*)array_list_get(jso->o.c_array, idx);
+       return (struct json_object*)array_list_get_idx(jso->o.c_array, idx);
 }
 
 static int json_array_equal(struct json_object* jso1,
index bbd0976ad7dfa4477861529b61dca9386f5996ac..4bbc367b6199d4f4475bd71d250b92e79ccd7b5d 100644 (file)
@@ -182,7 +182,7 @@ typedef enum json_type {
  *
  * @param obj the json_object instance
  */
-JSON_EXPORT struct json_object* json_object_retain(struct json_object *obj);
+JSON_EXPORT struct json_object* json_object_get(struct json_object *obj);
 
 /**
  * Decrement the reference count of json_object and free if it reaches zero.
@@ -192,7 +192,7 @@ JSON_EXPORT struct json_object* json_object_retain(struct json_object *obj);
  * @param obj the json_object instance
  * @returns 1 if the object was freed.
  */
-JSON_EXPORT int json_object_release(struct json_object *obj);
+JSON_EXPORT int json_object_put(struct json_object *obj);
 
 /**
  * Check if the json_object is of a given type
index 1023d2feb5b38e689bfce300e052ab3eec3971cf..2b2a9ef50732d5797c71915eb984fb4b6ba7dff3 100644 (file)
@@ -240,7 +240,7 @@ int json_pointer_set(struct json_object **obj, const char *path, struct json_obj
        }
 
        if (path[0] == '\0') {
-               json_object_release(*obj);
+               json_object_put(*obj);
                *obj = value;
                return 0;
        }
@@ -294,7 +294,7 @@ int json_pointer_setf(struct json_object **obj, struct json_object *value, const
                return rc;
 
        if (path_copy[0] == '\0') {
-               json_object_release(*obj);
+               json_object_put(*obj);
                *obj = value;
                goto out;
        }
index 08911fe89836bbc0b8b481a2581b85eff903ded3..57d8367ebf15d2d38414a1db6cabd6ee7c3291fc 100644 (file)
@@ -139,7 +139,7 @@ static void json_tokener_reset_level(struct json_tokener *tok, int depth)
 {
   tok->stack[depth].state = json_tokener_state_eatws;
   tok->stack[depth].saved_state = json_tokener_state_start;
-  json_object_release(tok->stack[depth].current);
+  json_object_put(tok->stack[depth].current);
   tok->stack[depth].current = NULL;
   free(tok->stack[depth].obj_field_name);
   tok->stack[depth].obj_field_name = NULL;
@@ -178,7 +178,7 @@ struct json_object* json_tokener_parse_verbose(const char *str,
     *error = tok->err;
     if(tok->err != json_tokener_success) {
                if (obj != NULL)
-                       json_object_release(obj);
+                       json_object_put(obj);
         obj = NULL;
     }
 
@@ -378,7 +378,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
 
     case json_tokener_state_finish:
       if(tok->depth == 0) goto out;
-      obj = json_object_retain(current);
+      obj = json_object_get(current);
       json_tokener_reset_level(tok, tok->depth);
       tok->depth--;
       goto redo_char;
@@ -959,7 +959,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
 
   if (tok->err == json_tokener_success)
   {
-    json_object *ret = json_object_retain(current);
+    json_object *ret = json_object_get(current);
        int ii;
 
        /* Partially reset, so we parse additional objects on subsequent calls. */