We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi.
I try to Use LZ4 Algorithm to comperes and decompress data. I want to use LZ4_compressHC function. this function don't work. if know that problem from calloc(1,s) function. "s" is a struct in library. I use STM32F407VGT MCU. All code are below:
char des[400];char des2[400];int res1;int res2;
int main()
{
sprintf(des,"This is test. just one statement write to test this function"); res2 = LZ4_compressHC((des),(des2), sizeof("This is test. just one statement write to test this function"));
}
int LZ4_compressHC(const char* source, char* dest, int inputSize){ void* ctx = LZ4_createHC(source); int result; if (ctx==NULL) return 0; result = LZ4HC_compress_generic (ctx, source, dest, inputSize, 0, noLimit); LZ4_freeHC(ctx); return result; }
void* LZ4_createHC (const char* inputBuffer){ void* hc4 = ALLOCATOR(sizeof(LZ4HC_Data_Structure)); LZ4_initHC ((LZ4HC_Data_Structure*)hc4, (const BYTE*)inputBuffer); return hc4;}
#define ALLOCATOR(s) calloc(1,s)
When " void* hc4 = ALLOCATOR(sizeof(LZ4HC_Data_Structure));" executed the output value is zero (hc4 = 0).
I try to solve it. sizeof(LZ4HC_Data_Structure) = 262160.
typedef struct { const BYTE* inputBuffer; const BYTE* base; const BYTE* end; HTYPE hashTable[HASHTABLESIZE]; U16 chainTable[MAXD]; const BYTE* nextToUpdate;} LZ4HC_Data_Structure;
why this very big? bigger than SRAM?