shithub: riscv

ref: 0ab5d34be4b8b9faa96d4691de95d6ae8c691f0b
dir: /sys/src/cmd/5l/compat.c/

View raw version
#include	"l.h"

/*
 * fake malloc
 */
void*
malloc(ulong n)
{
	void *p;

	while(n & 7)
		n++;
	while(nhunk < n)
		gethunk();
	p = hunk;
	nhunk -= n;
	hunk += n;
	return p;
}

void
free(void *p)
{
	USED(p);
}

void*
calloc(ulong m, ulong n)
{
	void *p;

	n *= m;
	p = malloc(n);
	memset(p, 0, n);
	return p;
}

void*
realloc(void *p, ulong n)
{
	fprint(2, "realloc(0x%p %ld) called\n", p, n);
	abort();
	return 0;
}

void*
mysbrk(ulong size)
{
	return sbrk(size);
}

void
setmalloctag(void *v, uintptr pc)
{
	USED(v, pc);
}