Lines Matching refs:lz4fRead
57 LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp) in LZ4F_readOpen() argument
64 if (fp == NULL || lz4fRead == NULL) { in LZ4F_readOpen()
68 *lz4fRead = (LZ4_readFile_t*)calloc(1, sizeof(LZ4_readFile_t)); in LZ4F_readOpen()
69 if (*lz4fRead == NULL) { in LZ4F_readOpen()
73 ret = LZ4F_createDecompressionContext(&(*lz4fRead)->dctxPtr, LZ4F_getVersion()); in LZ4F_readOpen()
75 free(*lz4fRead); in LZ4F_readOpen()
79 (*lz4fRead)->fp = fp; in LZ4F_readOpen()
80 consumedSize = fread(buf, 1, sizeof(buf), (*lz4fRead)->fp); in LZ4F_readOpen()
82 free(*lz4fRead); in LZ4F_readOpen()
86 ret = LZ4F_getFrameInfo((*lz4fRead)->dctxPtr, &info, buf, &consumedSize); in LZ4F_readOpen()
88 LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr); in LZ4F_readOpen()
89 free(*lz4fRead); in LZ4F_readOpen()
96 (*lz4fRead)->srcBufMaxSize = 64 * 1024; in LZ4F_readOpen()
99 (*lz4fRead)->srcBufMaxSize = 256 * 1024; in LZ4F_readOpen()
102 (*lz4fRead)->srcBufMaxSize = 1 * 1024 * 1024; in LZ4F_readOpen()
105 (*lz4fRead)->srcBufMaxSize = 4 * 1024 * 1024; in LZ4F_readOpen()
108 LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr); in LZ4F_readOpen()
109 free(*lz4fRead); in LZ4F_readOpen()
113 (*lz4fRead)->srcBuf = (LZ4_byte*)malloc((*lz4fRead)->srcBufMaxSize); in LZ4F_readOpen()
114 if ((*lz4fRead)->srcBuf == NULL) { in LZ4F_readOpen()
115 LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr); in LZ4F_readOpen()
116 free(lz4fRead); in LZ4F_readOpen()
120 (*lz4fRead)->srcBufSize = sizeof(buf) - consumedSize; in LZ4F_readOpen()
121 memcpy((*lz4fRead)->srcBuf, buf + consumedSize, (*lz4fRead)->srcBufSize); in LZ4F_readOpen()
126 size_t LZ4F_read(LZ4_readFile_t* lz4fRead, void* buf, size_t size) in LZ4F_read() argument
131 if (lz4fRead == NULL || buf == NULL) in LZ4F_read()
135 size_t srcsize = lz4fRead->srcBufSize - lz4fRead->srcBufNext; in LZ4F_read()
140 ret = fread(lz4fRead->srcBuf, 1, lz4fRead->srcBufMaxSize, lz4fRead->fp); in LZ4F_read()
142 lz4fRead->srcBufSize = ret; in LZ4F_read()
143 srcsize = lz4fRead->srcBufSize; in LZ4F_read()
144 lz4fRead->srcBufNext = 0; in LZ4F_read()
154 ret = LZ4F_decompress(lz4fRead->dctxPtr, in LZ4F_read()
156 lz4fRead->srcBuf + lz4fRead->srcBufNext, in LZ4F_read()
163 lz4fRead->srcBufNext += srcsize; in LZ4F_read()
171 LZ4F_errorCode_t LZ4F_readClose(LZ4_readFile_t* lz4fRead) in LZ4F_readClose() argument
173 if (lz4fRead == NULL) in LZ4F_readClose()
175 LZ4F_freeDecompressionContext(lz4fRead->dctxPtr); in LZ4F_readClose()
176 free(lz4fRead->srcBuf); in LZ4F_readClose()
177 free(lz4fRead); in LZ4F_readClose()