diff options
author | Thilo Schulz <arny@ats.s.bawue.de> | 2011-04-26 02:30:12 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-09 15:49:50 +0000 |
commit | 36cfed27430ed0f027aa47d47205d00f9718820c (patch) | |
tree | 668718f68a6a397668d4e9bb92691c05c2b95dca /src | |
parent | 2be571bfcb52c35e391b59f8dee7324c004dd1a7 (diff) |
Use memcmp instead of self-built while loop
Diffstat (limited to 'src')
-rw-r--r-- | src/qcommon/net_ip.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/qcommon/net_ip.c b/src/qcommon/net_ip.c index e3a95e4a..a64cd04e 100644 --- a/src/qcommon/net_ip.c +++ b/src/qcommon/net_ip.c @@ -390,7 +390,6 @@ Compare without port, and up to the bit number given in netmask. */ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask) { - qboolean differed; byte cmpmask, *addra, *addrb; int curbyte; @@ -422,24 +421,12 @@ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask) return qfalse; } - differed = qfalse; - curbyte = 0; + curbyte = netmask >> 3; - while(netmask > 7) - { - if(addra[curbyte] != addrb[curbyte]) - { - differed = qtrue; - break; - } - - curbyte++; - netmask -= 8; - } - - if(differed) - return qfalse; + if(curbyte && memcmp(addra, addrb, curbyte)) + return qfalse; + netmask &= ~0x07; if(netmask) { cmpmask = (1 << netmask) - 1; |