From 8b0f6efda8f97e304ee22d1ac8f0b0f31b3bb65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B5=E5=BF=97=E8=BF=9C?= Date: Wed, 20 Jul 2022 01:18:46 +0000 Subject: [PATCH] update user/app_singlepageheap.c. updated the user app. --- user/app_singlepageheap.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/user/app_singlepageheap.c b/user/app_singlepageheap.c index 61f8ba1..8c302fc 100644 --- a/user/app_singlepageheap.c +++ b/user/app_singlepageheap.c @@ -4,11 +4,19 @@ */ #include "user_lib.h" -#include "util/types.h" -#include "util/string.h" +//#include "util/string.h" + +typedef unsigned long long uint64; + +char* strcpy(char* dest, const char* src) { + char* d = dest; + while ((*d++ = *src++)) + ; + return dest; +} int main(void) { - char str[20] = "hello world."; + char str[20] = "hello, world!!!"; char *m = (char *)better_malloc(100); char *p = (char *)better_malloc(50); if((uint64)p - (uint64)m > 512 ){ @@ -19,6 +27,16 @@ int main(void) { strcpy(p,str); printu("%s\n",p); + char *n = (char *)better_malloc(50); + + if(m != n) + { + printu("your malloc is not complete.\n"); + exit(-1); + } +// else{ +// printu("0x%lx 0x%lx\n", m, n); +// } exit(0); return 0; }