Exemplo n.º 1
0
Arquivo: wrapper.c Projeto: Pistos/git
char *xstrdup(const char *str)
{
	char *ret = strdup(str);
	if (!ret) {
		release_pack_memory(strlen(str) + 1, -1);
		ret = strdup(str);
		if (!ret)
			die("Out of memory, strdup failed");
	}
	return ret;
}
Exemplo n.º 2
0
char *xstrdup(const char *str)
{
	char *ret = strdup(str);
	if (!ret) {
#if GIT_ENCWRAPPER_CUTOFF
		release_pack_memory(strlen(str) + 1, -1);
		ret = strdup(str);
		if (!ret)
#endif
			die("Out of memory, strdup failed");
	}
	return ret;
}
Exemplo n.º 3
0
Arquivo: wrapper.c Projeto: Pistos/git
void *xmmap(void *start, size_t length,
	int prot, int flags, int fd, off_t offset)
{
	void *ret = mmap(start, length, prot, flags, fd, offset);
	if (ret == MAP_FAILED) {
		if (!length)
			return NULL;
		release_pack_memory(length, fd);
		ret = mmap(start, length, prot, flags, fd, offset);
		if (ret == MAP_FAILED)
			die("Out of memory? mmap failed: %s", strerror(errno));
	}
	return ret;
}
Exemplo n.º 4
0
Arquivo: wrapper.c Projeto: Pistos/git
void *xcalloc(size_t nmemb, size_t size)
{
	void *ret = calloc(nmemb, size);
	if (!ret && (!nmemb || !size))
		ret = calloc(1, 1);
	if (!ret) {
		release_pack_memory(nmemb * size, -1);
		ret = calloc(nmemb, size);
		if (!ret && (!nmemb || !size))
			ret = calloc(1, 1);
		if (!ret)
			die("Out of memory, calloc failed");
	}
	return ret;
}
Exemplo n.º 5
0
Arquivo: wrapper.c Projeto: Pistos/git
void *xrealloc(void *ptr, size_t size)
{
	void *ret = realloc(ptr, size);
	if (!ret && !size)
		ret = realloc(ptr, 1);
	if (!ret) {
		release_pack_memory(size, -1);
		ret = realloc(ptr, size);
		if (!ret && !size)
			ret = realloc(ptr, 1);
		if (!ret)
			die("Out of memory, realloc failed");
	}
	return ret;
}
Exemplo n.º 6
0
void *xcalloc(size_t nmemb, size_t size)
{
	void *ret = calloc(nmemb, size);
	if (!ret && (!nmemb || !size))
		ret = calloc(1, 1);
	if (!ret) {
#if GIT_ENCWRAPPER_CUTOFF
		release_pack_memory(nmemb * size, -1);
		ret = calloc(nmemb, size);
		if (!ret && (!nmemb || !size))
			ret = calloc(1, 1);
		if (!ret)
#endif
			die("Out of memory, calloc failed");
	}
	return ret;
}
Exemplo n.º 7
0
void *xrealloc(void *ptr, size_t size)
{
	void *ret = realloc(ptr, size);
	if (!ret && !size)
		ret = realloc(ptr, 1);
	if (!ret) {
#if GIT_ENCWRAPPER_CUTOFF
		release_pack_memory(size, -1);
		ret = realloc(ptr, size);
		if (!ret && !size)
			ret = realloc(ptr, 1);
		if (!ret)
#endif
			die("Out of memory, realloc failed");
	}
	return ret;
}
Exemplo n.º 8
0
Arquivo: wrapper.c Projeto: Pistos/git
void *xmalloc(size_t size)
{
	void *ret = malloc(size);
	if (!ret && !size)
		ret = malloc(1);
	if (!ret) {
		release_pack_memory(size, -1);
		ret = malloc(size);
		if (!ret && !size)
			ret = malloc(1);
		if (!ret)
			die("Out of memory, malloc failed");
	}
#ifdef XMALLOC_POISON
	memset(ret, 0xA5, size);
#endif
	return ret;
}
Exemplo n.º 9
0
Arquivo: wrapper.c Projeto: Jinyan/git
static void try_to_free_builtin(size_t size)
{
	release_pack_memory(size, -1);
}