OBKF6SIIFFHHY7YWKPPX75N23NAVUD5662DKIHXSSIDPKKXQ5ZDQC
* Read the contents section of the open change file, decompress it and return
* the raw bytes.
*
* Returns a malloc()'ed byte buffer that the caller is responsible for
* deallocating. Returns NULL if the full contents could not be read, or the
* decompression failed, or some other error occurred.
* Read in an expected amount of bytes (or die failing), and decompress with
* zstd-seekable. Return a malloc()'ed byte buffer that the caller is in charge
* of free()'ing.
compressed_to_read = off->total - off->contents_off;
printf("expecting to read %lu bytes (compressed)\n", compressed_to_read);
compressed = calloc(sizeof(uint8_t), compressed_to_read);
printf("expecting to read %lu bytes (compressed)\n", compressed_len);
compressed = calloc(sizeof(uint8_t), compressed_len);
buf = decompress_segment(fd, comp_hashed_len, hashed_len);
if (buf == NULL) {
fprintf(stderr, "error: failed to decompress hashed segment\n");
return 1;
}
dump_buf("hashed", buf, hashed_len);
free(buf);
return 0;
}
/**
* Read the contents section of the open change file, decompress it and return
* the raw bytes.
*
* Returns a malloc()'ed byte buffer that the caller is responsible for
* deallocating. Returns NULL if the full contents could not be read, or the
* decompression failed, or some other error occurred.
*/
uint8_t *
change_read_contents(int fd, struct offsets *off)
{
return decompress_segment(fd, off->total - off->contents_off, off->contents_len);