aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntony Kellermann2018-07-27 08:36:48 -0400
committerAntony Kellermann2018-07-27 08:36:48 -0400
commitf02041f209c4263cea48e9acd9d01564b98c193c (patch)
treedd0e339ada7991238cc5a7f90c842540ebcefe39
parent4f1f9235d7766d71de283630428d75d92712f4cc (diff)
downloadaur-f02041f209c4263cea48e9acd9d01564b98c193c.tar.gz
Added info_array_get_info_from_symbol helper function
-rw-r--r--api.c8
-rw-r--r--api.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/api.c b/api.c
index 560c46258cff..6243425a3888 100644
--- a/api.c
+++ b/api.c
@@ -638,6 +638,14 @@ Ref_Data* iex_get_valid_symbols(void) {
return pRef_Data;
}
+Info* info_array_get_info_from_symbol(const Info_Array* pInfo_Array, const char* symbol) {
+ for (size_t i = 0; i < pInfo_Array->length; i++)
+ if (strcmp(symbol, pInfo_Array->array[i]->symbol) == 0)
+ return pInfo_Array->array[i];
+
+ return NULL;
+}
+
void api_ref_data_destroy(Ref_Data** phRef_Data) {
if (*phRef_Data == NULL)
return;
diff --git a/api.h b/api.h
index 9a21953906d8..c8c38587aee8 100644
--- a/api.h
+++ b/api.h
@@ -336,6 +336,15 @@ void info_array_store_totals(Info_Array* pInfo_Array);
Ref_Data* iex_get_valid_symbols(void);
/**
+ * Searches through an Info_Array and returns a ponter to the Info which has the same symbol as
+ * the function's argument. If not found, returns NULL.
+ * @param pInfo_Array the Info_Array to search
+ * @param symbol the symbol to match
+ * @return valid Info* or NULL if not found
+ */
+Info* info_array_get_info_from_symbol(const Info_Array* pInfo_Array, const char* symbol);
+
+/**
* Destroys Ref_Data object and frees memory. Sets the pointer of the Ref_Data to NULL
* @param phRef_Data the Ref_Data to destroy
*/