diff --git a/source/libs/grid/malloc/malloc.h b/source/libs/grid/include/malloc.h similarity index 78% rename from source/libs/grid/malloc/malloc.h rename to source/libs/grid/include/malloc.h index 46414ef..34eb6ef 100644 --- a/source/libs/grid/malloc/malloc.h +++ b/source/libs/grid/include/malloc.h @@ -11,5 +11,6 @@ #define _MALLOC_H bool init_malloc(); +void * malloc(size_t _Size); -#endif \ No newline at end of file +#endif diff --git a/source/libs/grid/stdlib/getenv.c b/source/libs/grid/stdlib/getenv.c index ad821de..e724e1c 100644 --- a/source/libs/grid/stdlib/getenv.c +++ b/source/libs/grid/stdlib/getenv.c @@ -14,6 +14,10 @@ #include #include #include "env.h" +#include "string.h" +#include "crt.h" +#include "malloc.h" +#include "stdio.h" extern char *_environ ; //����������ָ�� @@ -53,3 +57,4 @@ DLLEXPORT __weak char *getenv(const char * name) UNLOCK_ENV_VARIABLE; return NULL; } + diff --git a/source/libs/grid/stdlib/setenv.c b/source/libs/grid/stdlib/setenv.c index 248233b..6e268e5 100644 --- a/source/libs/grid/stdlib/setenv.c +++ b/source/libs/grid/stdlib/setenv.c @@ -13,11 +13,17 @@ #include #include #include "env.h" +#include "string.h" +#include "crt.h" +#include "malloc.h" +#include "stdio.h" char *_environ = NULL; //����������ָ�� char *_cur_env = NULL; //ָ�򻷾��������пռ��׵�ַ unsigned long _env_len = NULL; //��ǰ��������ָ����ָ��Ŀռ���ܴ�С +/* ������Ÿ�ʽ: ����+ֵ����+ֵ����*/ + DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrite) { char *p = _environ, *tmpp; @@ -53,19 +59,19 @@ DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrit { break; } - p = p + strlen(name) + __SIZE_OF_END_CHAR_; // name eof + p = p + strlen(name) + __SIZE_OF_END_CHAR_; memcpy(&oldlen, p, sizeof(int)); p += sizeof(int); - p += oldlen + __SIZE_OF_END_CHAR_; //eof + p += oldlen + __SIZE_OF_END_CHAR_; } ; - if (*p == 0) //������ + if (*p == 0) /*������ */ { p = _cur_env; strcpy(p, name); p += strlen(name); - *p = NULL; //eof + *p = NULL; p++; newlen = strlen(value); memcpy(p, (char*)&newlen, sizeof(int)); @@ -125,3 +131,4 @@ DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrit UNLOCK_ENV_VARIABLE; return 0; } +