* Concatenate pszSrc to pszDest and reallocate memory if necessary. */
| 1323 | * Concatenate pszSrc to pszDest and reallocate memory if necessary. |
| 1324 | */ |
| 1325 | char *msStringConcatenate(char *pszDest, const char *pszSrc) |
| 1326 | { |
| 1327 | int nLen; |
| 1328 | |
| 1329 | if (pszSrc == NULL) |
| 1330 | return pszDest; |
| 1331 | |
| 1332 | /* if destination is null, allocate memory */ |
| 1333 | if (pszDest == NULL) { |
| 1334 | pszDest = msStrdup(pszSrc); |
| 1335 | } |
| 1336 | else { /* if dest is not null, reallocate memory */ |
| 1337 | char *pszTemp; |
| 1338 | |
| 1339 | nLen = strlen(pszDest) + strlen(pszSrc); |
| 1340 | |
| 1341 | pszTemp = (char*)realloc(pszDest, nLen + 1); |
| 1342 | if (pszTemp) { |
| 1343 | pszDest = pszTemp; |
| 1344 | strcat(pszDest, pszSrc); |
| 1345 | pszDest[nLen] = '\0'; |
| 1346 | } |
| 1347 | else { |
| 1348 | msSetError(MS_MEMERR, "Error while reallocating memory.", "msStringConcatenate()"); |
| 1349 | return NULL; |
| 1350 | } |
| 1351 | } |
| 1352 | |
| 1353 | return pszDest; |
| 1354 | } |
| 1355 | |
| 1356 | char *msJoinStrings(char **array, int arrayLength, const char *delimeter) |
| 1357 | { |
no test coverage detected