//**************************************\r
#define MINMATCH 4\r
#define SKIPSTRENGTH 6\r
+#define HEAPLIMIT 13\r
\r
#define MAXD_LOG 16\r
#define MAX_DISTANCE ((1 << MAXD_LOG) - 1)\r
char* dest,\r
int isize)\r
{ \r
+#if HASH_LOG>HEAPLIMIT\r
struct refTables *srt = (struct refTables *) (*ctx);\r
const BYTE** HashTable;\r
+#else\r
+ const BYTE* HashTable[HASHTABLESIZE] = {0};\r
+#endif\r
\r
const BYTE* ip = (BYTE*) source; \r
const BYTE* anchor = ip;\r
\r
\r
// Init \r
+#if HASH_LOG>HEAPLIMIT\r
if (*ctx == NULL) \r
{\r
srt = (struct refTables *) malloc ( sizeof(struct refTables) );\r
}\r
HashTable = srt->hashTable;\r
memset((void*)HashTable, 0, sizeof(srt->hashTable));\r
+#endif\r
\r
\r
// First Byte\r
ip++; forwardH = HASH_VALUE(ip);\r
\r
// Main Loop\r
- for ( ; ; )
- {
- int segmentSize = (1U << skipStrength) + 3;
- const BYTE* forwardIp = ip;
- const BYTE* ref;
-
+ for ( ; ; ) \r
+ {\r
+ int segmentSize = (1U << skipStrength) + 3;\r
+ const BYTE* forwardIp = ip;\r
+ const BYTE* ref;\r
+\r
// Find a match\r
- do {
- U32 h = forwardH;
- int skipped = segmentSize++ >> skipStrength;
- ip = forwardIp;
- forwardIp = ip + skipped;
-
- if (forwardIp > ilimit) { goto _last_literals; }
+ do {\r
+ U32 h = forwardH;\r
+ int skipped = segmentSize++ >> skipStrength;\r
+ ip = forwardIp;\r
+ forwardIp = ip + skipped;\r
+\r
+ if (forwardIp > ilimit) { goto _last_literals; }\r
\r
forwardH = HASH_VALUE(forwardIp);\r
ref = HashTable[h];\r
HashTable[h] = ip;\r
-
- } while ((ref < ip - MAX_DISTANCE) || (*(U32*)ref != *(U32*)ip));
+\r
+ } while ((ref < ip - MAX_DISTANCE) || (*(U32*)ref != *(U32*)ip));\r
\r
// Catch up\r
while ((ip>anchor) && (ref>(BYTE*)source) && (ip[-1]==ref[-1])) { ip--; ref--; } \r
char* dest,\r
int isize)\r
{\r
+#if HASH_LOG>HEAPLIMIT\r
void* ctx = malloc(sizeof(struct refTables));\r
int result = LZ4_compressCtx(&ctx, source, dest, isize);\r
free(ctx);\r
-\r
return result;\r
+#else\r
+ return LZ4_compressCtx(NULL, source, dest, isize);\r
+#endif\r
}\r
\r
\r
\r
+\r
//****************************\r
// Decompression CODE\r
//****************************\r