shithub: femtolisp

ref: 3c817d2e586dd916e39d54b2722c2e41a17c898d
dir: /mem.c/

View raw version
#include "platform.h"

char *
fl_strdup(const char *s)
{
	size_t sz = strlen(s)+1;
	char *p = dlmalloc(sz);
	memcpy(p, s, sz);
	return p;
}

#if defined(__macos__)
#include <Multiverse.h>
void *
fl_sbrk(intptr_t increment)
{
	static char *e = nil;
	if(increment == 0)
		return e;
	char *p = NewPtr(increment);
	e = p + increment;
	return p;
}
#else
void *
fl_sbrk(intptr_t increment)
{
	return sbrk(increment);
}
#endif