From 8e49c375efebe4d49c4ad0ea07405c7ed2665ec2 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 19 Oct 2009 22:06:16 +0200 Subject: [PATCH] Add documentation of search_pattern() and wma_log2(). --- wma_common.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wma_common.c b/wma_common.c index 0df19ae9..84f075ed 100644 --- a/wma_common.c +++ b/wma_common.c @@ -21,10 +21,20 @@ #include "imdct.h" #include "wma.h" -const char *search_pattern(const char *pattern, int pattern_len, const char *buf, int buf_size) +/** + * Find the first occurrence of the given pattern. + * + * \param pattern The pattern to search for. + * \param pattern_len The length of the pattern in bytes. + * \param buf The buffer to search for the pattern. + * \param buf_size The number of bytes in \a buf. + */ +const char *search_pattern(const char *pattern, int pattern_len, + const char *buf, int buf_size) { const char *p, *end = buf + buf_size; + /* TODO: Use suffix arrays to speed up the search. */ for (p = buf; p + pattern_len < end; p++) { if (memcmp(p, pattern, pattern_len)) continue; @@ -125,6 +135,13 @@ const uint8_t log2_tab[256] = { 7, 7, 7, 7, 7, 7, 7, 7 }; +/** + * Compute the base-2 logarithm. + * + * \param v The value to compute the logarithm of. + * + * \return An integer approximation of log2(v). + */ int wma_log2(unsigned int v) { int n = 0; -- 2.39.2