Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created August 9, 2014 00:26
Show Gist options
  • Save andrewrk/60d4eb603bad701d3608 to your computer and use it in GitHub Desktop.
Save andrewrk/60d4eb603bad701d3608 to your computer and use it in GitHub Desktop.
static int memstrcmp(const char *mem, int mem_size, const char *str) {
for (int i = 0; i < mem_size; i++, str++) {
if (!*str || *str != mem[i])
return (mem[i] < *str) ? -1 : (mem[i] > *str);
}
return (*str > 0) ? -1 : 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment