MCPcopy Create free account
hub / github.com/git/git / zlib_deflate_raw

Function zlib_deflate_raw

archive-zip.c:204–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static void *zlib_deflate_raw(void *data, unsigned long size,
205 int compression_level,
206 unsigned long *compressed_size)
207{
208 git_zstream stream;
209 unsigned long maxsize;
210 void *buffer;
211 int result;
212
213 git_deflate_init_raw(&stream, compression_level);
214 maxsize = git_deflate_bound(&stream, size);
215 buffer = xmalloc(maxsize);
216
217 stream.next_in = data;
218 stream.avail_in = size;
219 stream.next_out = buffer;
220 stream.avail_out = maxsize;
221
222 do {
223 result = git_deflate(&stream, Z_FINISH);
224 } while (result == Z_OK);
225
226 if (result != Z_STREAM_END) {
227 free(buffer);
228 return NULL;
229 }
230
231 git_deflate_end(&stream);
232 *compressed_size = stream.total_out;
233
234 return buffer;
235}
236
237static void write_zip_data_desc(unsigned long size,
238 unsigned long compressed_size,

Callers 1

write_zip_entryFunction · 0.85

Calls 5

git_deflate_init_rawFunction · 0.85
git_deflate_boundFunction · 0.85
git_deflateFunction · 0.85
git_deflate_endFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected