mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
reftable/basics: stop using SWAP() macro
Stop using `SWAP()` macro in favor of an open-coded variant of it. Note that this also requires us to open-code the build assert that `SWAP()` itself uses to verify that the size of both variables matches. This is done to reduce our dependency on the Git codebase. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
10f2935c7f
commit
f8ed12dec4
@@ -266,6 +266,15 @@ static inline void *reftable_alloc_grow(void *p, size_t nelem, size_t elsize,
|
||||
# define strdup(str) REFTABLE_BANNED(strdup)
|
||||
#endif
|
||||
|
||||
#define REFTABLE_SWAP(a, b) do { \
|
||||
void *_swap_a_ptr = &(a); \
|
||||
void *_swap_b_ptr = &(b); \
|
||||
unsigned char _swap_buffer[sizeof(a) - 2 * sizeof(a) * (sizeof(a) != sizeof(b))]; \
|
||||
memcpy(_swap_buffer, _swap_a_ptr, sizeof(a)); \
|
||||
memcpy(_swap_a_ptr, _swap_b_ptr, sizeof(a)); \
|
||||
memcpy(_swap_b_ptr, _swap_buffer, sizeof(a)); \
|
||||
} while (0)
|
||||
|
||||
/* Find the longest shared prefix size of `a` and `b` */
|
||||
size_t common_prefix_size(struct reftable_buf *a, struct reftable_buf *b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user