git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob 12d547d70d132b2a6bd22053895af66bd3523c79 2101 bytes (raw)
name: reftable/publicbasics.c 	 # 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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
 
/*
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
*/

#include "reftable.h"

#include "basics.h"
#include "system.h"

const char *reftable_error_str(int err)
{
	static char buf[250];
	switch (err) {
	case REFTABLE_IO_ERROR:
		return "I/O error";
	case REFTABLE_FORMAT_ERROR:
		return "corrupt reftable file";
	case REFTABLE_NOT_EXIST_ERROR:
		return "file does not exist";
	case REFTABLE_LOCK_ERROR:
		return "data is outdated";
	case REFTABLE_API_ERROR:
		return "misuse of the reftable API";
	case REFTABLE_ZLIB_ERROR:
		return "zlib failure";
	case REFTABLE_NAME_CONFLICT:
		return "file/directory conflict";
	case REFTABLE_REFNAME_ERROR:
		return "invalid refname";
	case -1:
		return "general error";
	default:
		snprintf(buf, sizeof(buf), "unknown error code %d", err);
		return buf;
	}
}

int reftable_error_to_errno(int err)
{
	switch (err) {
	case REFTABLE_IO_ERROR:
		return EIO;
	case REFTABLE_FORMAT_ERROR:
		return EFAULT;
	case REFTABLE_NOT_EXIST_ERROR:
		return ENOENT;
	case REFTABLE_LOCK_ERROR:
		return EBUSY;
	case REFTABLE_API_ERROR:
		return EINVAL;
	case REFTABLE_ZLIB_ERROR:
		return EDOM;
	default:
		return ERANGE;
	}
}

static void *(*reftable_malloc_ptr)(size_t sz) = &malloc;
static void *(*reftable_realloc_ptr)(void *, size_t) = &realloc;
static void (*reftable_free_ptr)(void *) = &free;

void *reftable_malloc(size_t sz)
{
	return (*reftable_malloc_ptr)(sz);
}

void *reftable_realloc(void *p, size_t sz)
{
	return (*reftable_realloc_ptr)(p, sz);
}

void reftable_free(void *p)
{
	reftable_free_ptr(p);
}

void *reftable_calloc(size_t sz)
{
	void *p = reftable_malloc(sz);
	memset(p, 0, sz);
	return p;
}

void reftable_set_alloc(void *(*malloc)(size_t),
			void *(*realloc)(void *, size_t), void (*free)(void *))
{
	reftable_malloc_ptr = malloc;
	reftable_realloc_ptr = realloc;
	reftable_free_ptr = free;
}

int reftable_fd_write(void *arg, const void *data, size_t sz)
{
	int *fdp = (int *)arg;
	return write(*fdp, data, sz);
}

debug log:

solving 12d547d70d ...
found 12d547d70d in https://public-inbox.org/git/eaf4629b-d8c4-0ddc-8c85-6600399a8229@ramsayjones.plus.com/ ||
	https://public-inbox.org/git/4190da597e65bce072fa3c37c9410a56def4b489.1601568663.git.gitgitgadget@gmail.com/
found a31463ff9a in https://public-inbox.org/git/570a8c4bcac54295865ee0fc4514073b59725511.1600283416.git.gitgitgadget@gmail.com/

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


applying [2/2] https://public-inbox.org/git/eaf4629b-d8c4-0ddc-8c85-6600399a8229@ramsayjones.plus.com/
diff --git a/reftable/publicbasics.c b/reftable/publicbasics.c
index a31463ff9a..12d547d70d 100644

Checking patch reftable/publicbasics.c...
Applied patch reftable/publicbasics.c cleanly.
Checking patch reftable/publicbasics.c...
Applied patch reftable/publicbasics.c cleanly.

skipping https://public-inbox.org/git/4190da597e65bce072fa3c37c9410a56def4b489.1601568663.git.gitgitgadget@gmail.com/ for 12d547d70d
index at:
100644 12d547d70d132b2a6bd22053895af66bd3523c79	reftable/publicbasics.c

(*) 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).