Skip to content

Commit

Permalink
Add guard macros and declare the functions inline so that the file ca…
Browse files Browse the repository at this point in the history
…n be dropped into other projects without modifications.
  • Loading branch information
FooBarWidget committed Dec 4, 2010
1 parent 401b3f3 commit f76e233
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions StreamBoyerMooreHorspool.cpp
Expand Up @@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _STREAM_BOYER_MOORE_HORSPOOL_
#define _STREAM_BOYER_MOORE_HORSPOOL_

/*
* Boyer-Moore-Horspool string search algorithm implementation with streaming support.
Expand Down Expand Up @@ -199,13 +201,13 @@ struct StreamBMH {
#endif


void
inline void
sbmh_reset(struct StreamBMH *restrict ctx) {
ctx->found = false;
ctx->lookbehind_size = 0;
}

void
inline void
sbmh_init(struct StreamBMH *restrict ctx, const unsigned char *restrict needle,
sbmh_size_t needle_len)
{
Expand All @@ -231,7 +233,7 @@ sbmh_init(struct StreamBMH *restrict ctx, const unsigned char *restrict needle,
}
}

static char
inline char
sbmh_lookup_char(const struct StreamBMH *restrict ctx,
const unsigned char *restrict data, ssize_t pos)
{
Expand All @@ -242,7 +244,7 @@ sbmh_lookup_char(const struct StreamBMH *restrict ctx,
}
}

static bool
inline bool
sbmh_memcmp(const struct StreamBMH *restrict ctx,
const unsigned char *restrict needle, const unsigned char *restrict data,
ssize_t pos, sbmh_size_t len)
Expand All @@ -262,7 +264,7 @@ sbmh_memcmp(const struct StreamBMH *restrict ctx,
return true;
}

size_t
inline size_t
sbmh_feed(struct StreamBMH *restrict ctx,
const unsigned char *restrict needle, sbmh_size_t needle_len,
const unsigned char *restrict data, size_t len)
Expand Down Expand Up @@ -435,3 +437,5 @@ sbmh_feed(struct StreamBMH *restrict ctx,

return len;
}

#endif /* _STREAM_BOYER_MOORE_HORSPOOL_ */

0 comments on commit f76e233

Please sign in to comment.