WCHAR* _wcsdup(const WCHAR* strSource) { WCHAR* strDestination; if (strSource == NULL) return NULL; #if sun strDestination = wsdup(strSource); #elif defined(__APPLE__) && defined(__MACH__) strDestination = malloc(wcslen(strSource)); if (strDestination != NULL) wcscpy(strDestination, strSource); #else strDestination = (WCHAR*) wcsdup((wchar_t*) strSource); #endif if (strDestination == NULL) perror("wcsdup"); return strDestination; }
WCHAR* _wcsdup(const WCHAR* strSource) { WCHAR* strDestination; if (strSource == NULL) return NULL; #if defined(sun) && sun strDestination = wsdup(strSource); #elif defined(__APPLE__) && defined(__MACH__) || defined(ANDROID) strDestination = malloc(wcslen((wchar_t*)strSource)); if (strDestination != NULL) wcscpy((wchar_t*)strDestination, (const wchar_t*)strSource); #else strDestination = (WCHAR*) wcsdup((wchar_t*) strSource); #endif if (strDestination == NULL) WLog_ERR(TAG,"wcsdup"); return strDestination; }
wchar_t* xwcsdup(const wchar_t* wstr) { wchar_t* mem; if (wstr == NULL) return NULL; #ifdef _WIN32 mem = _wcsdup(wstr); #elif sun mem = wsdup(wstr); #elif (defined(__APPLE__) && defined(__MACH__)) || defined(ANDROID) mem = xmalloc(wcslen(wstr)); if (mem != NULL) wcscpy(mem, wstr); #else mem = wcsdup(wstr); #endif if (mem == NULL) perror("wstrdup"); return mem; }