Changeset 16378 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Jan 29, 2009 4:51:48 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/string.cpp
r16369 r16378 53 53 size_t i = pos; 54 54 while (*psz && i--) 55 if ( !(RT_SUCCESS(RTStrGetCpEx(&psz, &cp))))55 if (RT_FAILURE(RTStrGetCpEx(&psz, &cp))) 56 56 return ret; // return empty string on bad encoding 57 57 … … 65 65 i = n; 66 66 while (*psz && i--) 67 if ( !(RT_SUCCESS(RTStrGetCpEx(&psz, &cp))))67 if (RT_FAILURE(RTStrGetCpEx(&psz, &cp))) 68 68 return ret; // return empty string on bad encoding 69 69 70 70 size_t len = psz - pFirst; 71 #if 1 71 72 char *psz = (char*)RTMemAlloc(len + 1); 72 73 memcpy(psz, pFirst, len); … … 74 75 ret = psz; 75 76 RTMemFree(psz); 77 #else /* A proposal that saves a memcpy and alloc/free: */ 78 ret.alloc(len + 1); 79 memcpy(ret.str, pFirst, len); 80 ret.str[len] = '\0'; 81 #endif 76 82 } 77 83 }
Note:
See TracChangeset
for help on using the changeset viewer.