@matheusbsbs / matheus-bagliano / commits / 62f255ad58
Fork 0

Make trivial wrapper functions around delta base generation and freeing

This doesn't change any code, it just creates a point for where we'd actually do the caching of delta bases that have been generated. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Mar 17, 2007 at 12:42 UTC 62f255ad586a987461c96b1da123da5e2cc3f619
1 file changed +14 -2
sha1_file.c
+14 -2
@@ -1352,6 +1352,18 @@ static void *unpack_compressed_entry(struct packed_git *p,
1352 return buffer;
1353 }
1354
1355 +static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
1356 + unsigned long *base_size, enum object_type *type)
1357 +{
1358 + return unpack_entry(p, base_offset, type, base_size);
1359 +}
1360 +
1361 +static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
1362 + void *base, unsigned long base_size, enum object_type type)
1363 +{
1364 + free(base);
1365 +}
1366 +
1367 static void *unpack_delta_entry(struct packed_git *p,
1368 struct pack_window **w_curs,
1369 off_t curpos,
@@ -1365,7 +1377,7 @@ static void *unpack_delta_entry(struct packed_git *p,
1377 off_t base_offset;
1378
1379 base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset);
1368 - base = unpack_entry(p, base_offset, type, &base_size);
1380 + base = cache_or_unpack_entry(p, base_offset, &base_size, type);
1381 if (!base)
1382 die("failed to read delta base object"
1383 " at %"PRIuMAX" from %s",
@@ -1378,7 +1390,7 @@ static void *unpack_delta_entry(struct packed_git *p,
1390 if (!result)
1391 die("failed to apply delta");
1392 free(delta_data);
1381 - free(base);
1393 + add_delta_base_cache(p, base_offset, base, base_size, *type);
1394 return result;
1395 }
1396