link_alt_odb_entries(): take (char *, len) rather than two pointers

Change link_alt_odb_entries() to take the length of the "alt" parameter rather than a pointer to the end of the "alt" string. This is the more common calling convention and simplifies the code a tiny bit. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>

Michael Haggerty committed Nov 5, 2012 at 09:41 UTC c595016402620ba93e79064f6e3bc9e09981e680
1 file changed +5 -5
sha1_file.c
+5 -5
@@ -317,7 +317,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
317 return 0;
318 }
319
320 -static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
320 +static void link_alt_odb_entries(const char *alt, int len, int sep,
321 const char *relative_base, int depth)
322 {
323 struct string_list entries = STRING_LIST_INIT_NODUP;
@@ -330,7 +330,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
330 return;
331 }
332
333 - alt_copy = xmemdupz(alt, ep - alt);
333 + alt_copy = xmemdupz(alt, len);
334 string_list_split_in_place(&entries, alt_copy, sep, -1);
335 for (i = 0; i < entries.nr; i++) {
336 const char *entry = entries.items[i].string;
@@ -371,7 +371,7 @@ void read_info_alternates(const char * relative_base, int depth)
371 map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
372 close(fd);
373
374 - link_alt_odb_entries(map, map + mapsz, '\n', relative_base, depth);
374 + link_alt_odb_entries(map, mapsz, '\n', relative_base, depth);
375
376 munmap(map, mapsz);
377 }
@@ -385,7 +385,7 @@ void add_to_alternates_file(const char *reference)
385 if (commit_lock_file(lock))
386 die("could not close alternates file");
387 if (alt_odb_tail)
388 - link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0);
388 + link_alt_odb_entries(alt, strlen(alt), '\n', NULL, 0);
389 }
390
391 void foreach_alt_odb(alt_odb_fn fn, void *cb)
@@ -409,7 +409,7 @@ void prepare_alt_odb(void)
409 if (!alt) alt = "";
410
411 alt_odb_tail = &alt_odb_list;
412 - link_alt_odb_entries(alt, alt + strlen(alt), PATH_SEP, NULL, 0);
412 + link_alt_odb_entries(alt, strlen(alt), PATH_SEP, NULL, 0);
413
414 read_info_alternates(get_object_directory(), 0);
415 }