ulthar.xyz > Repos

leibowitz

Experimental Common Lisp object storage abstraction for Unix file systems
About Files Commits git clone https://ulthar.xyz/repos/leibowitz/leibowitz.git

leibowitz/client/utils.c

Download raw file: client/utils.c

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#include "utils.h"

void *
xcalloc(size_t nmemb, size_t size, const char *const extra_msg)
{
	void *p = calloc(nmemb, size);
	if (!p) {
		perror("calloc");
		if (extra_msg) fprintf(stderr, "%s\n", extra_msg);
		exit(1);
	}
	return p;
}

long
xstrtol(const char *const nptr, char **endptr, const int base,
    const char *const extra_msg)
{
	long r = strtol(nptr, endptr, base);
	if (errno) {
		perror("strtol");
		if (extra_msg) fprintf(stderr, "%s\n", extra_msg);
		exit(1);
	}
	return r;
}
Generated 2024-06-10 19:24:14 -0700 by RepoRat