From 72e143396c4aee4255dba07e63805e464816895f Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 20 May 2018 09:56:24 -0700 Subject: [PATCH] Add two utility functions to function_list. --- include/function_list.h | 13 +++++++++++++ src/function_list.c | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/include/function_list.h b/include/function_list.h index 852b11c..b09b3dd 100644 --- a/include/function_list.h +++ b/include/function_list.h @@ -31,6 +31,19 @@ libab_result libab_function_list_init(libab_function_list* list); */ libab_result libab_function_list_insert(libab_function_list* list, libab_ref* function_value); +/** + * Get the size of the given function list. + * @param list the list to get the size of. + * @return the size of the list. + */ +size_t libab_function_list_size(libab_function_list* list); +/** + * Gets a value at the given index in the list. + * @param list the list to get a value from. + * @param index the index at which to get the value. + * @param into the reference to store the function into. + */ +void libab_function_list_index(libab_function_list* list, size_t index, libab_ref* into); /** * Frees the given function list. * @param list the list to free. diff --git a/src/function_list.c b/src/function_list.c index 4400549..60e924f 100644 --- a/src/function_list.c +++ b/src/function_list.c @@ -9,6 +9,14 @@ libab_result libab_function_list_insert(libab_function_list* list, return libab_ref_vec_insert(&list->functions, function); } +size_t libab_function_list_size(libab_function_list* list) { + return list->functions.size; +} + +void libab_function_list_index(libab_function_list* list, size_t index, libab_ref* into) { + libab_ref_vec_index(&list->functions, index, into); +} + void libab_function_list_free(libab_function_list* list) { libab_ref_vec_free(&list->functions); }