X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_string.c;h=7950934d8b91fb75971cf6e8baae121491cb8cba;hb=2cb41f7db5b9f89113432d6b3daff4807ba8e5f2;hp=75a8975a289c9ad869e86b6d1019f747800bbf64;hpb=3a64514e2fbdb79da57b289fc94b336b78046ba2;p=palacios.git diff --git a/palacios/src/palacios/vmm_string.c b/palacios/src/palacios/vmm_string.c index 75a8975..7950934 100644 --- a/palacios/src/palacios/vmm_string.c +++ b/palacios/src/palacios/vmm_string.c @@ -71,6 +71,11 @@ void * memcpy(void * dst, const void * src, size_t n) { #ifdef V3_CONFIG_BUILT_IN_MEMMOVE void * memmove(void * dst, const void * src, size_t n) { uint8_t * tmp = (uint8_t *)V3_Malloc(n); + + if (!tmp) { + PrintError(info->vm_info, info, "Cannot allocate in built-in memmove\n"); + return NULL; + } memcpy(tmp, src, n); memcpy(dst, tmp, n); @@ -285,6 +290,12 @@ char * strdup(const char * s1) { char *ret; ret = V3_Malloc(strlen(s1) + 1); + + if (!ret) { + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in built-in strdup\n"); + return NULL; + } + strcpy(ret, s1); return ret; @@ -309,6 +320,7 @@ int atoi(const char * buf) { #endif +#ifdef V3_CONFIG_BUILT_IN_STRTOI int strtoi(const char * nptr, char ** endptr) { int ret = 0; char * buf = (char *)nptr; @@ -326,7 +338,9 @@ int strtoi(const char * nptr, char ** endptr) { return ret; } +#endif +#ifdef V3_CONFIG_BUILT_IN_ATOX uint64_t atox(const char * buf) { uint64_t ret = 0; @@ -348,7 +362,9 @@ uint64_t atox(const char * buf) { return ret; } +#endif +#ifdef V3_CONFIG_BUILT_IN_STRTOX uint64_t strtox(const char * nptr, char ** endptr) { uint64_t ret = 0; char * buf = (char *)nptr; @@ -376,7 +392,7 @@ uint64_t strtox(const char * nptr, char ** endptr) { return ret; } - +#endif #ifdef V3_CONFIG_BUILT_IN_STRCHR @@ -494,7 +510,7 @@ char *strstr(const char *haystack, const char *needle) } #endif - +#ifdef V3_CONFIG_BUILT_IN_STR_TOLOWER void str_tolower(char * s) { while (isalpha(*s)) { if (!islower(*s)) { @@ -503,8 +519,9 @@ void str_tolower(char * s) { s++; } } +#endif - +#ifdef V3_CONFIG_BUILT_IN_STR_TOUPPER void str_toupper(char * s) { while (isalpha(*s)) { if (!isupper(*s)) { @@ -513,3 +530,4 @@ void str_toupper(char * s) { s++; } } +#endif