commit - 301e83b3580ad6750144e2e36393b74e6fd6adcb
commit + aabb25f81b1f8f68a03af422f9ae14ea5c3ae1fd
blob - 7319d5ef83b73fc2ce80bffde945fc06670f947f
blob + be8dabb4b70569ee825b8a9571f0915a88776478
--- 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)