X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/d0fd08fab7a646c47fae21491c8d8f1c2b790a2c..d38e1f468376f8b19b208f2da4d20cb2919875dd:/keyarray.h diff --git a/keyarray.h b/keyarray.h index 86c5991..5be7b78 100644 --- a/keyarray.h +++ b/keyarray.h @@ -1,5 +1,6 @@ -/* - * keyarray.h - routines to maintain a sorted array of keyids. +/** + * @file keyarray.h + * @brief Routines to maintain a sorted array of keyids. * * Copyright 2004 Jonathan McDowell * @@ -23,14 +24,43 @@ #include #include +/** + * @brief A sorted array of keyids + * + * Holds a sorted list of keyids, with room for growth - has details of both + * the total size of the array as well as the current number of elements. + */ struct keyarray { + /** The array of key ids */ uint64_t *keys; + /** Number of key ids in the array */ size_t count; + /** Total size of the array */ size_t size; }; +/** + * @brief Given a key array figure out of a key id is present + * @param array Pointer to the key array + * @param key The keyid to look for + */ bool array_find(struct keyarray *array, uint64_t key); + +/** + * @brief Free a key array + * @param array Pointer to the key array to free + */ void array_free(struct keyarray *array); + +/** + * @brief Add a keyid to a key array + * @param array Pointer to the key array + * @param key The keyid to add + * + * Checks if the key already exists in the key array and if not adds it. + * Returns true if the key was added, false if it was found to be already + * present. + */ bool array_add(struct keyarray *array, uint64_t key); #endif /* __KEYARRAY_H__ */