Revision 27ac2b1f24d034f89e87d79768fe94a4e7559b93 authored by Junio C Hamano on 14 March 2014, 21:27:23 UTC, committed by Junio C Hamano on 14 March 2014, 21:27:23 UTC
* ta/parse-commit-with-skip-prefix: commit.c: use skip_prefix() instead of starts_with()
memmem.c
#include "../git-compat-util.h"
void *gitmemmem(const void *haystack, size_t haystack_len,
const void *needle, size_t needle_len)
{
const char *begin = haystack;
const char *last_possible = begin + haystack_len - needle_len;
const char *tail = needle;
char point;
/*
* The first occurrence of the empty string is deemed to occur at
* the beginning of the string.
*/
if (needle_len == 0)
return (void *)begin;
/*
* Sanity check, otherwise the loop might search through the whole
* memory.
*/
if (haystack_len < needle_len)
return NULL;
point = *tail++;
for (; begin <= last_possible; begin++) {
if (*begin == point && !memcmp(begin + 1, tail, needle_len - 1))
return (void *)begin;
}
return NULL;
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...