Git fork
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 REFTABLE_BASICS_H
10#define REFTABLE_BASICS_H
11
12#include <stddef.h>
13
14/* A buffer that contains arbitrary byte slices. */
15struct reftable_buf {
16 size_t alloc;
17 size_t len;
18 char *buf;
19};
20#define REFTABLE_BUF_INIT { 0 }
21
22/*
23 * Hash functions understood by the reftable library. Note that the values are
24 * arbitrary and somewhat random such that we can easily detect cases where the
25 * hash hasn't been properly set up.
26 */
27enum reftable_hash {
28 REFTABLE_HASH_SHA1 = 89,
29 REFTABLE_HASH_SHA256 = 247,
30};
31#define REFTABLE_HASH_SIZE_SHA1 20
32#define REFTABLE_HASH_SIZE_SHA256 32
33#define REFTABLE_HASH_SIZE_MAX REFTABLE_HASH_SIZE_SHA256
34
35/* Overrides the functions to use for memory management. */
36void reftable_set_alloc(void *(*malloc)(size_t),
37 void *(*realloc)(void *, size_t), void (*free)(void *));
38
39#endif