Created
December 12, 2012 20:45
-
-
Save kulp/4271440 to your computer and use it in GitHub Desktop.
Revisions
-
kulp revised this gist
Dec 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ unsigned check_range(const char *bad, const char *good, size_t len, size_t bound { if (len < 2) { if (len) return *bad != *good; return 0; } else if (memcmp(bad, good, len)) { size_t subbounds[2][2] = { { 0 } }; -
kulp revised this gist
Dec 12, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ unsigned check_range(const char *bad, const char *good, size_t len, size_t bounds[2]) { if (len < 2) { if (len) return *(const char*)bad != *(const char*)good; return 0; } else if (memcmp(bad, good, len)) { size_t subbounds[2][2] = { { 0 } }; int leftbad = check_range(&bad[0 ], &good[0 ], len / 2, subbounds[0]); int rightbad = check_range(&bad[len / 2], &good[len / 2], len - len / 2, subbounds[1]); -
kulp revised this gist
Dec 12, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ unsigned check_range(const void *bad, const void *good, size_t len, size_t bound return *(const char*)bad != *(const char*)good; return 0; } else if (memcmp(bad, good, len)) { size_t subbounds[2][2] = { 0 }; int leftbad = check_range(&bad[0 ], &good[0 ], len / 2, subbounds[0]); int rightbad = check_range(&bad[len / 2], &good[len / 2], len - len / 2, subbounds[1]); -
kulp created this gist
Dec 12, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ unsigned check_range(const void *bad, const void *good, size_t len, size_t bounds[2]) { if (len < 2) { if (len) return *(const char*)bad != *(const char*)good; return 0; } else if (memcmp(bad, good, len)) { size_t subbounds[2][2] = { 0 }; int leftbad = check_range(&bad[0 ], &good[0 ], len / 2, subbounds[0]); int rightbad = check_range(&bad[len / 2], &good[len / 2], len - len / 2, subbounds[1]); // return leftmost and rightmost bad bounds bounds[0] = subbounds[ leftbad ? 0 : 1][0] + ( leftbad ? 0 : len - len / 2); bounds[1] = subbounds[rightbad ? 1 : 0][1] + (rightbad ? len - len / 2 : 0); return leftbad + rightbad; } else { return 0; } }