return 0;
}
+int array_list_set_idx(struct array_list *arr, size_t idx, void *data)
+{
+ if (idx >= arr->length)
+ return -1;
+ arr->array[idx] = data;
+ return 0;
+}
+
int array_list_add(struct array_list *arr, void *data)
{
/* Repeat some of array_list_put_idx() so we can skip several
extern int array_list_add(struct array_list *al, void *data);
+/**
+ * Set the value at index i. Caller is responsible for freeing the previous value.
+ * To automatically free the existing value, use array_list_put_idx() instead.
+ */
+extern int array_list_set_idx(struct array_list *al, size_t i, void *data);
+
extern size_t array_list_length(struct array_list *al);
extern void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *));
array_list_free;
array_list_new;
array_list_put_idx;
+ array_list_set_idx;
array_list_sort;
json_hex_chars;
json_parse_double;
json_parse_uint64;
lh_table_delete;
lh_table_delete_entry;
+ lh_table_delete_entry_to_tail;
lh_table_free;
lh_table_insert;
lh_table_insert_w_hash;
return 0;
}
+int lh_table_delete_entry_to_tail(struct lh_table *t, struct lh_entry *first_entry)
+{
+ struct lh_entry *del_entry = t->tail;
+ do
+ {
+ // Could probably micro-optimize this, but better to avoid code duplication for now
+ if (lh_table_delete_entry(t, del_entry) != 0)
+ return -1;
+ } while (del_entry != first_entry);
+ return 0;
+}
+
int lh_table_delete(struct lh_table *t, const void *k)
{
struct lh_entry *e = lh_table_lookup_entry(t, k);
*/
extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
+/**
+ * Delete all entries from the specified one to the tail of the list.
+ * Same as calling lh_table_delete_entry() on each of them.
+ *
+ * @param t the table to delete from.
+ * @param e a pointer to the first entry to delete.
+ * @return 0 if the item was deleted.
+ * @return -1 if it was not found.
+ */
+extern int lh_table_delete_entry_to_tail(struct lh_table *t, struct lh_entry *e);
+
/**
* Delete a record from the table.
*