shithub: riscv

ref: 5f7a6b7ea3c4ae1b51beffe3309e9b6b0491e71f
dir: /sys/src/cmd/cc/compat.c/

View raw version
#include	"cc.h"
#include	"compat"

/*
 * fake mallocs
 */
void*
malloc(ulong n)
{
	return alloc(n);
}

void*
calloc(ulong m, ulong n)
{
	return alloc(m*n);
}

void*
realloc(void *o, ulong n)
{
	ulong m;
	void *a;

	if(n == 0)
		return nil;
	if(o == nil)
		return alloc(n);
	a = alloc(n);
	m = (char*)a - (char*)o;
	if(m < n)
		n = m;
	memmove(a, o, n);
	return a;
}

void
free(void*)
{
}

/* needed when profiling */
void*
mallocz(ulong size, int clr)
{
	void *v;

	v = alloc(size);
	if(clr && v != nil)
		memset(v, 0, size);
	return v;
}

void
setmalloctag(void*, uintptr)
{
}

void
setrealloctag(void*, uintptr)
{
}