mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
dht: remove custom memmem
This commit is contained in:
1 parent
2e38a307f9
commit
0ea48ed1de
2 files changed
-33
No files matched your search
@@ -895,9 +895,6 @@ private:
|
||||
|
||||
bool rateLimit();
|
||||
bool neighbourhoodMaintenance(RoutingTable&);
|
||||
|
||||
static void *dht_memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
-30
@@ -3226,34 +3226,4 @@ Dht::ParsedMessage::msgpack_unpack(msgpack::object msg)
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
|
||||
#ifdef HAVE_MEMMEM
|
||||
|
||||
void *
|
||||
Dht::dht_memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
|
||||
{
|
||||
return memmem(haystack, haystacklen, needle, needlelen);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void *
|
||||
Dht::dht_memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
|
||||
{
|
||||
const char *h = (const char *)haystack;
|
||||
const char *n = (const char *)needle;
|
||||
size_t i;
|
||||
|
||||
/* size_t is unsigned */
|
||||
if (needlelen > haystacklen)
|
||||
return nullptr;
|
||||
|
||||
for (i = 0; i <= haystacklen - needlelen; i++) {
|
||||
if (memcmp(h + i, n, needlelen) == 0)
|
||||
return (void*)(h + i);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user