git/wrapper.c

/*
 * Various trivial helper wrappers around standard functions
 */
#include "git-compat-util.h"
#include "abspath.h"
#include "parse.h"
#include "gettext.h"
#include "strbuf.h"
#include "trace2.h"

#ifdef HAVE_RTLGENRANDOM
/* This is required to get access to RtlGenRandom. */
#define SystemFunction036
#include <ntsecapi.h>
#undef SystemFunction036
#endif

static int memory_limit_check(size_t size, int gentle)
{}

char *xstrdup(const char *str)
{}

static void *do_xmalloc(size_t size, int gentle)
{}

void *xmalloc(size_t size)
{}

static void *do_xmallocz(size_t size, int gentle)
{}

void *xmallocz(size_t size)
{}

void *xmallocz_gently(size_t size)
{}

/*
 * xmemdupz() allocates (len + 1) bytes of memory, duplicates "len" bytes of
 * "data" to the allocated memory, zero terminates the allocated memory,
 * and returns a pointer to the allocated memory. If the allocation fails,
 * the program dies.
 */
void *xmemdupz(const void *data, size_t len)
{}

char *xstrndup(const char *str, size_t len)
{}

int xstrncmpz(const char *s, const char *t, size_t len)
{}

void *xrealloc(void *ptr, size_t size)
{}

void *xcalloc(size_t nmemb, size_t size)
{}

void xsetenv(const char *name, const char *value, int overwrite)
{}

/**
 * xopen() is the same as open(), but it die()s if the open() fails.
 */
int xopen(const char *path, int oflag, ...)
{}

static int handle_nonblock(int fd, short poll_events, int err)
{}

/*
 * xread() is the same a read(), but it automatically restarts read()
 * operations with a recoverable error (EAGAIN and EINTR). xread()
 * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
 */
ssize_t xread(int fd, void *buf, size_t len)
{}

/*
 * xwrite() is the same a write(), but it automatically restarts write()
 * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
 * GUARANTEE that "len" bytes is written even if the operation is successful.
 */
ssize_t xwrite(int fd, const void *buf, size_t len)
{}

/*
 * xpread() is the same as pread(), but it automatically restarts pread()
 * operations with a recoverable error (EAGAIN and EINTR). xpread() DOES
 * NOT GUARANTEE that "len" bytes is read even if the data is available.
 */
ssize_t xpread(int fd, void *buf, size_t len, off_t offset)
{}

ssize_t read_in_full(int fd, void *buf, size_t count)
{}

ssize_t write_in_full(int fd, const void *buf, size_t count)
{}

ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset)
{}

int xdup(int fd)
{}

/**
 * xfopen() is the same as fopen(), but it die()s if the fopen() fails.
 */
FILE *xfopen(const char *path, const char *mode)
{}

FILE *xfdopen(int fd, const char *mode)
{}

FILE *fopen_for_writing(const char *path)
{}

static void warn_on_inaccessible(const char *path)
{}

int warn_on_fopen_errors(const char *path)
{}

FILE *fopen_or_warn(const char *path, const char *mode)
{}

int xmkstemp(char *filename_template)
{}

/* Adapted from libiberty's mkstemp.c. */

#undef TMP_MAX
#define TMP_MAX

int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
{}

int git_mkstemp_mode(char *pattern, int mode)
{}

int xmkstemp_mode(char *filename_template, int mode)
{}

/*
 * Some platforms return EINTR from fsync. Since fsync is invoked in some
 * cases by a wrapper that dies on failure, do not expose EINTR to callers.
 */
static int fsync_loop(int fd)
{}

int git_fsync(int fd, enum fsync_action action)
{}

static int warn_if_unremovable(const char *op, const char *file, int rc)
{}

int unlink_or_msg(const char *file, struct strbuf *err)
{}

int unlink_or_warn(const char *file)
{}

int rmdir_or_warn(const char *file)
{}

static int access_error_is_ok(int err, unsigned flag)
{}

int access_or_warn(const char *path, int mode, unsigned flag)
{}

int access_or_die(const char *path, int mode, unsigned flag)
{}

char *xgetcwd(void)
{}

int xsnprintf(char *dst, size_t max, const char *fmt, ...)
{}

void write_file_buf(const char *path, const char *buf, size_t len)
{}

void write_file(const char *path, const char *fmt, ...)
{}

void sleep_millisec(int millisec)
{}

int xgethostname(char *buf, size_t len)
{}

int is_empty_or_missing_file(const char *filename)
{}

int open_nofollow(const char *path, int flags)
{}

int csprng_bytes(void *buf, size_t len)
{}

uint32_t git_rand(void)
{}