git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob c2d7aca8dd0131f88f0cb309a17187852a69fcb6 2018 bytes (raw)
name: reftable/strbuf.h 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#ifndef SLICE_H
#define SLICE_H

#ifdef REFTABLE_STANDALONE

#include "basics.h"

/*
  Provides a bounds-checked, growable byte ranges. To use, initialize as "strbuf
  x = STRBUF_INIT;"
 */
struct strbuf {
	size_t len;
	size_t cap;
	char *buf;

	/* Used to enforce initialization with STRBUF_INIT */
	uint8_t canary;
};

#define STRBUF_CANARY 0x42
#define STRBUF_INIT                       \
	{                                 \
		0, 0, NULL, STRBUF_CANARY \
	}

void strbuf_addstr(struct strbuf *dest, const char *src);

/* Deallocate and clear strbuf */
void strbuf_release(struct strbuf *strbuf);

/* Set strbuf to 0 length, but retain buffer. */
void strbuf_reset(struct strbuf *strbuf);

/* Initializes a strbuf. Accepts a strbuf with random garbage. */
void strbuf_init(struct strbuf *strbuf, size_t alloc);

/* Return `buf`, clearing out `s`. Optionally return len (not cap) in `sz`.  */
char *strbuf_detach(struct strbuf *s, size_t *sz);

/* Set length of the slace to `l`, but don't reallocated. */
void strbuf_setlen(struct strbuf *s, size_t l);

/* Ensure `l` bytes beyond current length are available */
void strbuf_grow(struct strbuf *s, size_t l);

/* Signed comparison */
int strbuf_cmp(const struct strbuf *a, const struct strbuf *b);

/* Append `data` to the `dest` strbuf.  */
int strbuf_add(struct strbuf *dest, const void *data, size_t sz);

/* Append `add` to `dest. */
void strbuf_addbuf(struct strbuf *dest, struct strbuf *add);

#else

#include "../git-compat-util.h"
#include "../strbuf.h"

#endif

extern struct strbuf reftable_empty_strbuf;

/* Like strbuf_add, but suitable for passing to reftable_new_writer
 */
int strbuf_add_void(void *b, const void *data, size_t sz);

/* Find the longest shared prefix size of `a` and `b` */
int common_prefix_size(struct strbuf *a, struct strbuf *b);

#endif

debug log:

solving c2d7aca8dd ...
found c2d7aca8dd in https://public-inbox.org/git/570a8c4bcac54295865ee0fc4514073b59725511.1600283416.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/4190da597e65bce072fa3c37c9410a56def4b489.1601568663.git.gitgitgadget@gmail.com/

applying [1/1] https://public-inbox.org/git/570a8c4bcac54295865ee0fc4514073b59725511.1600283416.git.gitgitgadget@gmail.com/
diff --git a/reftable/strbuf.h b/reftable/strbuf.h
new file mode 100644
index 0000000000..c2d7aca8dd

Checking patch reftable/strbuf.h...
Applied patch reftable/strbuf.h cleanly.

skipping https://public-inbox.org/git/4190da597e65bce072fa3c37c9410a56def4b489.1601568663.git.gitgitgadget@gmail.com/ for c2d7aca8dd
index at:
100644 c2d7aca8dd0131f88f0cb309a17187852a69fcb6	reftable/strbuf.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).