From 5719e608b404c5f566ab2410047ba07ebe02d588 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 4 Jan 2007 10:17:34 +0000 Subject: [XEN] Avoid use of GNU-specific memmem(). Signed-off-by: Keir Fraser --- xen/tools/symbols.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'xen/tools') diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c index ed126a2d06..00f1a43037 100644 --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -350,6 +350,14 @@ static void build_initial_tok_table(void) table_cnt = pos; } +static void *memmem_pvt(void *h, size_t hlen, void *n, size_t nlen) +{ + char *p; + for (p = h; (p - (char *)h) <= (hlen - nlen); p++) + if (!memcmp(p, n, nlen)) return p; + return NULL; +} + /* replace a given token in all the valid symbols. Use the sampled symbols * to update the counts */ static void compress_symbols(unsigned char *str, int idx) @@ -363,7 +371,7 @@ static void compress_symbols(unsigned char *str, int idx) p1 = table[i].sym; /* find the token on the symbol */ - p2 = memmem(p1, len, str, 2); + p2 = memmem_pvt(p1, len, str, 2); if (!p2) continue; /* decrease the counts for this symbol's tokens */ @@ -382,7 +390,7 @@ static void compress_symbols(unsigned char *str, int idx) if (size < 2) break; /* find the token on the symbol */ - p2 = memmem(p1, size, str, 2); + p2 = memmem_pvt(p1, size, str, 2); } while (p2); -- cgit v1.2.3