Coverage Report

Created: 2020-05-07 18:36

/proc/self/cwd/c/basics.h
Line
Count
Source
1
/*
2
Copyright 2020 Google LLC
3
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
7
*/
8
9
#ifndef BASICS_H
10
#define BASICS_H
11
12
#include "system.h"
13
14
#include "reftable.h"
15
16
35.7k
#define true 1
17
28.5k
#define false 0
18
19
/* Bigendian en/decoding of integers */
20
21
void put_be24(byte *out, uint32_t i);
22
uint32_t get_be24(byte *in);
23
void put_be16(uint8_t *out, uint16_t i);
24
25
/*
26
  find smallest index i in [0, sz) at which f(i) is true, assuming
27
  that f is ascending. Return sz if f(i) is false for all indices.
28
*/
29
int binsearch(size_t sz, int (*f)(size_t k, void *args), void *args);
30
31
/*
32
  Frees a NULL terminated array of malloced strings. The array itself is also
33
  freed.
34
 */
35
void free_names(char **a);
36
37
/* parse a newline separated list of names. Empty names are discarded. */
38
void parse_names(char *buf, int size, char ***namesp);
39
40
/* compares two NULL-terminated arrays of strings. */
41
int names_equal(char **a, char **b);
42
43
/* returns the array size of a NULL-terminated array of strings. */
44
int names_length(char **names);
45
46
/* Allocation routines; they invoke the functions set through
47
 * reftable_set_alloc() */
48
void *reftable_malloc(size_t sz);
49
void *reftable_realloc(void *p, size_t sz);
50
void reftable_free(void *p);
51
void *reftable_calloc(size_t sz);
52
53
#endif