ia64/xen-unstable

changeset 13251:bdbfbfdfbd64

[XEN] Avoid use of GNU-specific memmem().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Jan 04 10:17:34 2007 +0000 (2007-01-04)
parents 60f91c9f1a24
children 60e50c65f862
files xen/tools/symbols.c
line diff
     1.1 --- a/xen/tools/symbols.c	Wed Jan 03 23:53:27 2007 +0000
     1.2 +++ b/xen/tools/symbols.c	Thu Jan 04 10:17:34 2007 +0000
     1.3 @@ -350,6 +350,14 @@ static void build_initial_tok_table(void
     1.4  	table_cnt = pos;
     1.5  }
     1.6  
     1.7 +static void *memmem_pvt(void *h, size_t hlen, void *n, size_t nlen)
     1.8 +{
     1.9 +	char *p;
    1.10 +	for (p = h; (p - (char *)h) <= (hlen - nlen); p++)
    1.11 +		if (!memcmp(p, n, nlen)) return p;
    1.12 +	return NULL;
    1.13 +}
    1.14 +
    1.15  /* replace a given token in all the valid symbols. Use the sampled symbols
    1.16   * to update the counts */
    1.17  static void compress_symbols(unsigned char *str, int idx)
    1.18 @@ -363,7 +371,7 @@ static void compress_symbols(unsigned ch
    1.19  		p1 = table[i].sym;
    1.20  
    1.21  		/* find the token on the symbol */
    1.22 -		p2 = memmem(p1, len, str, 2);
    1.23 +		p2 = memmem_pvt(p1, len, str, 2);
    1.24  		if (!p2) continue;
    1.25  
    1.26  		/* decrease the counts for this symbol's tokens */
    1.27 @@ -382,7 +390,7 @@ static void compress_symbols(unsigned ch
    1.28  			if (size < 2) break;
    1.29  
    1.30  			/* find the token on the symbol */
    1.31 -			p2 = memmem(p1, size, str, 2);
    1.32 +			p2 = memmem_pvt(p1, size, str, 2);
    1.33  
    1.34  		} while (p2);
    1.35