commit - fc16ecdf72bdc27684fed33e40cfaad4a7018517
commit + 723ed5ad7b6b4e64fb94f1b356e4cfbf4c86edac
blob - 37bc22a5cd985ace5fde99d2e50c1b8d3c9fc820
blob + b32ea0c0007766add7513ffdeb536b75266ec0a7
--- lib/pack.c
+++ lib/pack.c
delta->type != GOT_OBJ_TYPE_BLOB &&
delta->type != GOT_OBJ_TYPE_TAG) {
const struct got_error *err;
- uint8_t *delta_buf;
+ uint8_t *delta_buf = NULL;
size_t delta_len;
int cached = 1;
- got_delta_cache_get(&delta_buf, &delta_len,
- pack->delta_cache, delta->data_offset);
+ if (pack->delta_cache) {
+ got_delta_cache_get(&delta_buf, &delta_len,
+ pack->delta_cache, delta->data_offset);
+ }
if (delta_buf == NULL) {
cached = 0;
err = read_delta_data(&delta_buf, &delta_len,
NULL, delta->data_offset, pack);
if (err)
return err;
+ }
+ if (pack->delta_cache && !cached) {
err = got_delta_cache_add(pack->delta_cache,
delta->data_offset, delta_buf, delta_len);
if (err == NULL)
{
const struct got_error *err = NULL;
struct got_delta *delta;
- uint8_t *base_buf = NULL, *accum_buf = NULL, *delta_buf;
+ uint8_t *base_buf = NULL, *accum_buf = NULL;
size_t base_bufsz = 0, accum_bufsz = 0, accum_size = 0, delta_len;
/* We process small enough files entirely in memory for speed. */
const size_t max_bufsize = GOT_DELTA_RESULT_SIZE_CACHED_MAX;
/* Deltas are ordered in ascending order. */
STAILQ_FOREACH(delta, &deltas->entries, entry) {
+ uint8_t *delta_buf = NULL;
uint64_t base_size, result_size = 0;
int cached = 1;
if (n == 0) {
continue;
}
- got_delta_cache_get(&delta_buf, &delta_len,
- pack->delta_cache, delta->data_offset);
+ if (pack->delta_cache) {
+ got_delta_cache_get(&delta_buf, &delta_len,
+ pack->delta_cache, delta->data_offset);
+ }
if (delta_buf == NULL) {
cached = 0;
err = read_delta_data(&delta_buf, &delta_len, NULL,
delta->data_offset, pack);
if (err)
goto done;
+ }
+ if (pack->delta_cache && !cached) {
err = got_delta_cache_add(pack->delta_cache,
delta->data_offset, delta_buf, delta_len);
if (err == NULL)
{
const struct got_error *err = NULL;
struct got_delta *delta;
- uint8_t *base_buf = NULL, *accum_buf = NULL, *delta_buf;
+ uint8_t *base_buf = NULL, *accum_buf = NULL;
size_t base_bufsz = 0, accum_bufsz = 0, accum_size = 0, delta_len;
uint64_t max_size = 0;
int n = 0;
/* Deltas are ordered in ascending order. */
STAILQ_FOREACH(delta, &deltas->entries, entry) {
+ uint8_t *delta_buf = NULL;
uint64_t base_size, result_size = 0;
int cached = 1;
if (n == 0) {
continue;
}
- got_delta_cache_get(&delta_buf, &delta_len,
- pack->delta_cache, delta->data_offset);
+ if (pack->delta_cache) {
+ got_delta_cache_get(&delta_buf, &delta_len,
+ pack->delta_cache, delta->data_offset);
+ }
if (delta_buf == NULL) {
cached = 0;
err = read_delta_data(&delta_buf, &delta_len, NULL,
delta->data_offset, pack);
if (err)
goto done;
+ }
+ if (pack->delta_cache && !cached) {
err = got_delta_cache_add(pack->delta_cache,
delta->data_offset, delta_buf, delta_len);
if (err == NULL)