2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
13 * miscellaneous utilities that are not provided by Git.
18 /* Bigendian en/decoding of integers */
20 void put_be24(uint8_t *out
, uint32_t i
);
21 uint32_t get_be24(uint8_t *in
);
22 void put_be16(uint8_t *out
, uint16_t i
);
25 * find smallest index i in [0, sz) at which f(i) is true, assuming
26 * that f is ascending. Return sz if f(i) is false for all indices.
28 * Contrary to bsearch(3), this returns something useful if the argument is not
31 int binsearch(size_t sz
, int (*f
)(size_t k
, void *args
), void *args
);
34 * Frees a NULL terminated array of malloced strings. The array itself is also
37 void free_names(char **a
);
39 /* parse a newline separated list of names. `size` is the length of the buffer,
40 * without terminating '\0'. Empty names are discarded. */
41 void parse_names(char *buf
, int size
, char ***namesp
);
43 /* compares two NULL-terminated arrays of strings. */
44 int names_equal(char **a
, char **b
);
46 /* returns the array size of a NULL-terminated array of strings. */
47 int names_length(char **names
);
49 /* Allocation routines; they invoke the functions set through
50 * reftable_set_alloc() */
51 void *reftable_malloc(size_t sz
);
52 void *reftable_realloc(void *p
, size_t sz
);
53 void reftable_free(void *p
);
54 void *reftable_calloc(size_t sz
);
56 /* Find the longest shared prefix size of `a` and `b` */
58 int common_prefix_size(struct strbuf
*a
, struct strbuf
*b
);