// 说明:参数和用法都类似strchr、strstr、memchr这些函数。
void* membin(const void* mem, unsigned int mem_count, const void* bin, unsigned int bin_count)
{
char* src = (char*)mem;
int max_cmp_count = (int)(mem_count - bin_count) + 1;
int i = 0;
if ( mem && bin && max_cmp_count > 0 )
{
for ( i = 0; i < max_cmp_count; ++i )
{
if ( 0 == memcmp(src, bin, bin_count) )
{
return (void*)src;
}
else
{
src += 1;
}
}
}
return NULL;
}