Created
February 3, 2015 22:51
-
-
Save sergey-dryabzhinsky/7f09a390c546288bf75b to your computer and use it in GitHub Desktop.
zstd simple and ugly test case output
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 characters
$ git diff | |
diff --git a/lib/fse.c b/lib/fse.c | |
index a1aeea5..bee6afc 100644 | |
--- a/lib/fse.c | |
+++ b/lib/fse.c | |
@@ -84,6 +84,7 @@ | |
#include <stdlib.h> /* malloc, free, qsort */ | |
#include <string.h> /* memcpy, memset */ | |
#include <stdio.h> /* printf (debug) */ | |
+#include <assert.h> /* assert (debug) */ | |
#include "fse_static.h" | |
@@ -624,11 +625,26 @@ static size_t FSE_adjustNormSlow(short* norm, int pointsToRemove, const unsigned | |
if (norm[rank[0].id] == 1) | |
rank[0].count=0; | |
savedR = rank[0]; | |
- while (rank[newRank].count > savedR.count) | |
+ while (rank[newRank].count > savedR.count && newRank <= FSE_MAX_SYMBOL_VALUE) | |
{ | |
+ if (newRank > FSE_MAX_SYMBOL_VALUE) { | |
+ fprintf(stderr, "saved rank count: %d\n", savedR.count); | |
+ fprintf(stderr, "Ranks:\n"); | |
+ for (s=0; s<=FSE_MAX_SYMBOL_VALUE; s++) { | |
+ fprintf(stderr, "- index: %d, count=%d\n", s, rank[s].count); | |
+ } | |
+ | |
+ fprintf(stderr, "Original counts:\n"); | |
+ for (s=0; s<=FSE_MAX_SYMBOL_VALUE; s++) { | |
+ fprintf(stderr, "- index: %d, count=%d\n", s, count[s]); | |
+ } | |
+ | |
+ assert(newRank <= FSE_MAX_SYMBOL_VALUE); | |
+ } | |
rank[newRank-1] = rank[newRank]; | |
newRank++; | |
} | |
+ assert((newRank - 1) <= FSE_MAX_SYMBOL_VALUE); | |
rank[newRank-1] = savedR; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment