@@ -656,81 +656,6 @@ void initialize_repository_version(int hash_algo, int reinit);
656
656
void sanitize_stdfds (void );
657
657
int daemonize (void );
658
658
659
- #define alloc_nr (x ) (((x)+16)*3/2)
660
-
661
- /**
662
- * Dynamically growing an array using realloc() is error prone and boring.
663
- *
664
- * Define your array with:
665
- *
666
- * - a pointer (`item`) that points at the array, initialized to `NULL`
667
- * (although please name the variable based on its contents, not on its
668
- * type);
669
- *
670
- * - an integer variable (`alloc`) that keeps track of how big the current
671
- * allocation is, initialized to `0`;
672
- *
673
- * - another integer variable (`nr`) to keep track of how many elements the
674
- * array currently has, initialized to `0`.
675
- *
676
- * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
677
- * alloc)`. This ensures that the array can hold at least `n` elements by
678
- * calling `realloc(3)` and adjusting `alloc` variable.
679
- *
680
- * ------------
681
- * sometype *item;
682
- * size_t nr;
683
- * size_t alloc
684
- *
685
- * for (i = 0; i < nr; i++)
686
- * if (we like item[i] already)
687
- * return;
688
- *
689
- * // we did not like any existing one, so add one
690
- * ALLOC_GROW(item, nr + 1, alloc);
691
- * item[nr++] = value you like;
692
- * ------------
693
- *
694
- * You are responsible for updating the `nr` variable.
695
- *
696
- * If you need to specify the number of elements to allocate explicitly
697
- * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
698
- *
699
- * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
700
- * added niceties.
701
- *
702
- * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
703
- */
704
- #define ALLOC_GROW (x , nr , alloc ) \
705
- do { \
706
- if ((nr) > alloc) { \
707
- if (alloc_nr(alloc) < (nr)) \
708
- alloc = (nr); \
709
- else \
710
- alloc = alloc_nr(alloc); \
711
- REALLOC_ARRAY(x, alloc); \
712
- } \
713
- } while (0)
714
-
715
- /*
716
- * Similar to ALLOC_GROW but handles updating of the nr value and
717
- * zeroing the bytes of the newly-grown array elements.
718
- *
719
- * DO NOT USE any expression with side-effect for any of the
720
- * arguments.
721
- */
722
- #define ALLOC_GROW_BY (x , nr , increase , alloc ) \
723
- do { \
724
- if (increase) { \
725
- size_t new_nr = nr + (increase); \
726
- if (new_nr < nr) \
727
- BUG("negative growth in ALLOC_GROW_BY"); \
728
- ALLOC_GROW(x, new_nr, alloc); \
729
- memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
730
- nr = new_nr; \
731
- } \
732
- } while (0)
733
-
734
659
/* Initialize and use the cache information */
735
660
struct lock_file ;
736
661
void preload_index (struct index_state * index ,
0 commit comments