mescc: Tinycc support: malloc,memcpy.
* mlibc/libc-mes.c (malloc): Rewrite. * mlibc/libc-mes+tcc.c (memcpy): Implement.
This commit is contained in:
parent
ba78b78203
commit
ab74876131
|
@ -148,7 +148,10 @@ longjmp (jmp_buf env, int val)
|
||||||
void *
|
void *
|
||||||
memcpy (void *dest, void const *src, size_t n)
|
memcpy (void *dest, void const *src, size_t n)
|
||||||
{
|
{
|
||||||
return 0;
|
char* p = dest;
|
||||||
|
char* q = src;
|
||||||
|
while (n--) *p++ = *q++;
|
||||||
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
|
|
@ -311,10 +311,11 @@ char *g_brk = 0;
|
||||||
void *
|
void *
|
||||||
malloc (size_t size)
|
malloc (size_t size)
|
||||||
{
|
{
|
||||||
if (!g_brk) g_brk = brk (0);
|
if (!g_brk)
|
||||||
char *p = g_brk;
|
g_brk = brk (0);
|
||||||
if (size < 0 || brk (g_brk + size) == -1)
|
if (brk (g_brk + size) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
char *p = g_brk;
|
||||||
g_brk += size;
|
g_brk += size;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue