aboutsummaryrefslogtreecommitdiff
path: root/libbb/git.h
blob: 07ef93bf4ac1efac4cc52d8ced7ecac245f286fd (plain)
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
ssize_t write_in_full(int fd, const void *buf, size_t count);
void *xcalloc(size_t nmemb, size_t size);
ssize_t _xwrite(int fd, const void *buf, size_t len);
ssize_t _xread(int fd, void *buf, size_t len);

#define alloc_nr(x) (((x)+16)*3/2)

#define ALLOC_GROW(x, nr, alloc) \
	do { \
		if ((nr) > alloc) { \
			if (alloc_nr(alloc) < (nr)) \
				alloc = (nr); \
			else \
				alloc = alloc_nr(alloc); \
			x = xrealloc((x), alloc * sizeof(*(x))); \
		} \
	} while(0)

static inline int is_absolute_path(const char *path)
{
	return path[0] == '/' || has_dos_drive_prefix(path);
}

#define NORETURN ATTRIBUTE_NORETURN
#define die bb_error_msg_and_die
#define error(...) fprintf(stderr, __VA_ARGS__)