summaryrefslogtreecommitdiff
path: root/devel/jansson/files/patch-src_value.c
blob: 1f6d76e48d71a49a63f2a48505ee28257f641eb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
--- src/value.c.orig	2018-11-26 08:10:21 UTC
+++ src/value.c
@@ -374,20 +374,20 @@ size_t json_array_size(const json_t *json)
     return json_to_array(json)->entries;
 }
 
-json_t *json_array_get(const json_t *json, size_t index)
+json_t *json_array_get(const json_t *json, size_t idx)
 {
     json_array_t *array;
     if(!json_is_array(json))
         return NULL;
     array = json_to_array(json);
 
-    if(index >= array->entries)
+    if(idx >= array->entries)
         return NULL;
 
-    return array->table[index];
+    return array->table[idx];
 }
 
-int json_array_set_new(json_t *json, size_t index, json_t *value)
+int json_array_set_new(json_t *json, size_t idx, json_t *value)
 {
     json_array_t *array;
 
@@ -401,14 +401,14 @@ int json_array_set_new(json_t *json, size_t index, jso
     }
     array = json_to_array(json);
 
-    if(index >= array->entries)
+    if(idx >= array->entries)
     {
         json_decref(value);
         return -1;
     }
 
-    json_decref(array->table[index]);
-    array->table[index] = value;
+    json_decref(array->table[idx]);
+    array->table[idx] = value;
 
     return 0;
 }
@@ -480,7 +480,7 @@ int json_array_append_new(json_t *json, json_t *value)
     return 0;
 }
 
-int json_array_insert_new(json_t *json, size_t index, json_t *value)
+int json_array_insert_new(json_t *json, size_t idx, json_t *value)
 {
     json_array_t *array;
     json_t **old_table;
@@ -494,7 +494,7 @@ int json_array_insert_new(json_t *json, size_t index, 
     }
     array = json_to_array(json);
 
-    if(index > array->entries) {
+    if(idx > array->entries) {
         json_decref(value);
         return -1;
     }
@@ -506,21 +506,21 @@ int json_array_insert_new(json_t *json, size_t index, 
     }
 
     if(old_table != array->table) {
-        array_copy(array->table, 0, old_table, 0, index);
-        array_copy(array->table, index + 1, old_table, index,
-                   array->entries - index);
+        array_copy(array->table, 0, old_table, 0, idx);
+        array_copy(array->table, idx + 1, old_table, idx,
+                   array->entries - idx);
         jsonp_free(old_table);
     }
     else
-        array_move(array, index + 1, index, array->entries - index);
+        array_move(array, idx + 1, idx, array->entries - idx);
 
-    array->table[index] = value;
+    array->table[idx] = value;
     array->entries++;
 
     return 0;
 }
 
-int json_array_remove(json_t *json, size_t index)
+int json_array_remove(json_t *json, size_t idx)
 {
     json_array_t *array;
 
@@ -528,14 +528,14 @@ int json_array_remove(json_t *json, size_t index)
         return -1;
     array = json_to_array(json);
 
-    if(index >= array->entries)
+    if(idx >= array->entries)
         return -1;
 
-    json_decref(array->table[index]);
+    json_decref(array->table[idx]);
 
     /* If we're removing the last element, nothing has to be moved */
-    if(index < array->entries - 1)
-        array_move(array, index, index + 1, array->entries - index - 1);
+    if(idx < array->entries - 1)
+        array_move(array, idx, idx + 1, array->entries - idx - 1);
 
     array->entries--;