mescc: Tinycc support: malloc,memcpy.

* mlibc/libc-mes.c (malloc): Rewrite.
* mlibc/libc-mes+tcc.c (memcpy): Implement.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-27 18:51:58 +02:00
parent ba78b78203
commit ab74876131
2 changed files with 8 additions and 4 deletions

View file

@ -148,7 +148,10 @@ longjmp (jmp_buf env, int val)
void *
memcpy (void *dest, void const *src, size_t n)
{
return 0;
char* p = dest;
char* q = src;
while (n--) *p++ = *q++;
return dest;
}
void *

View file

@ -311,10 +311,11 @@ char *g_brk = 0;
void *
malloc (size_t size)
{
if (!g_brk) g_brk = brk (0);
char *p = g_brk;
if (size < 0 || brk (g_brk + size) == -1)
if (!g_brk)
g_brk = brk (0);
if (brk (g_brk + size) == -1)
return 0;
char *p = g_brk;
g_brk += size;
return p;
}