Skip to content

Commit ce481ac

Browse files
committed
Merge branch 'cw/compat-util-header-cleanup'
Further shuffling of declarations across header files to streamline file dependencies. * cw/compat-util-header-cleanup: git-compat-util: move alloc macros to git-compat-util.h treewide: remove unnecessary includes for wrapper.h kwset: move translation table from ctype sane-ctype.h: create header for sane-ctype macros git-compat-util: move wrapper.c funcs to its header git-compat-util: move strbuf.c funcs to its header
2 parents d5bb430 + 91c080d commit ce481ac

File tree

147 files changed

+327
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+327
-478
lines changed

add-patch.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "git-compat-util.h"
22
#include "add-interactive.h"
33
#include "advice.h"
4-
#include "alloc.h"
54
#include "editor.h"
65
#include "environment.h"
76
#include "gettext.h"

alias.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "git-compat-util.h"
22
#include "alias.h"
3-
#include "alloc.h"
43
#include "config.h"
54
#include "gettext.h"
65
#include "strbuf.h"

alloc.h

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,79 +17,4 @@ void *alloc_object_node(struct repository *r);
1717
struct alloc_state *allocate_alloc_state(void);
1818
void clear_alloc_state(struct alloc_state *s);
1919

20-
#define alloc_nr(x) (((x)+16)*3/2)
21-
22-
/**
23-
* Dynamically growing an array using realloc() is error prone and boring.
24-
*
25-
* Define your array with:
26-
*
27-
* - a pointer (`item`) that points at the array, initialized to `NULL`
28-
* (although please name the variable based on its contents, not on its
29-
* type);
30-
*
31-
* - an integer variable (`alloc`) that keeps track of how big the current
32-
* allocation is, initialized to `0`;
33-
*
34-
* - another integer variable (`nr`) to keep track of how many elements the
35-
* array currently has, initialized to `0`.
36-
*
37-
* Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
38-
* alloc)`. This ensures that the array can hold at least `n` elements by
39-
* calling `realloc(3)` and adjusting `alloc` variable.
40-
*
41-
* ------------
42-
* sometype *item;
43-
* size_t nr;
44-
* size_t alloc
45-
*
46-
* for (i = 0; i < nr; i++)
47-
* if (we like item[i] already)
48-
* return;
49-
*
50-
* // we did not like any existing one, so add one
51-
* ALLOC_GROW(item, nr + 1, alloc);
52-
* item[nr++] = value you like;
53-
* ------------
54-
*
55-
* You are responsible for updating the `nr` variable.
56-
*
57-
* If you need to specify the number of elements to allocate explicitly
58-
* then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
59-
*
60-
* Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
61-
* added niceties.
62-
*
63-
* DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
64-
*/
65-
#define ALLOC_GROW(x, nr, alloc) \
66-
do { \
67-
if ((nr) > alloc) { \
68-
if (alloc_nr(alloc) < (nr)) \
69-
alloc = (nr); \
70-
else \
71-
alloc = alloc_nr(alloc); \
72-
REALLOC_ARRAY(x, alloc); \
73-
} \
74-
} while (0)
75-
76-
/*
77-
* Similar to ALLOC_GROW but handles updating of the nr value and
78-
* zeroing the bytes of the newly-grown array elements.
79-
*
80-
* DO NOT USE any expression with side-effect for any of the
81-
* arguments.
82-
*/
83-
#define ALLOC_GROW_BY(x, nr, increase, alloc) \
84-
do { \
85-
if (increase) { \
86-
size_t new_nr = nr + (increase); \
87-
if (new_nr < nr) \
88-
BUG("negative growth in ALLOC_GROW_BY"); \
89-
ALLOC_GROW(x, new_nr, alloc); \
90-
memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
91-
nr = new_nr; \
92-
} \
93-
} while (0)
94-
9520
#endif

apply.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "git-compat-util.h"
1111
#include "abspath.h"
12-
#include "alloc.h"
1312
#include "base85.h"
1413
#include "config.h"
1514
#include "object-store-ll.h"
@@ -37,7 +36,6 @@
3736
#include "symlinks.h"
3837
#include "wildmatch.h"
3938
#include "ws.h"
40-
#include "wrapper.h"
4139

4240
struct gitdiff_data {
4341
struct strbuf *root;

archive-tar.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copyright (c) 2005, 2006 Rene Scharfe
33
*/
44
#include "git-compat-util.h"
5-
#include "alloc.h"
65
#include "config.h"
76
#include "gettext.h"
87
#include "git-zlib.h"

archive.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "git-compat-util.h"
22
#include "abspath.h"
3-
#include "alloc.h"
43
#include "config.h"
54
#include "convert.h"
65
#include "environment.h"

attr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
#include "git-compat-util.h"
10-
#include "alloc.h"
1110
#include "config.h"
1211
#include "environment.h"
1312
#include "exec-cmd.h"

builtin/am.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "path.h"
4545
#include "repository.h"
4646
#include "pretty.h"
47-
#include "wrapper.h"
4847

4948
/**
5049
* Returns the length of the first line of msg.

builtin/bisect.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "prompt.h"
1616
#include "quote.h"
1717
#include "revision.h"
18-
#include "wrapper.h"
1918

2019
static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
2120
static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")

builtin/blame.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#include "git-compat-util.h"
9-
#include "alloc.h"
109
#include "config.h"
1110
#include "color.h"
1211
#include "builtin.h"

0 commit comments

Comments
 (0)