MCPcopy Create free account
hub / github.com/apache/nuttx / double_appdir_backslashes

Function double_appdir_backslashes

tools/configure.c:1236–1287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236static char *double_appdir_backslashes(char *old_appdir)
1237{
1238 char *new_appdir = NULL;
1239 char *p_old = NULL;
1240 char *p_new = NULL;
1241 int oldlen = 0;
1242 int occurrences = 0;
1243 int alloclen = 0;
1244
1245 p_old = old_appdir;
1246 while ((p_old = strchr(p_old, '\\')) != NULL)
1247 {
1248 occurrences++;
1249 p_old++;
1250 }
1251
1252 if (occurrences != 0)
1253 {
1254 oldlen = strlen(old_appdir);
1255 alloclen = oldlen + occurrences + sizeof((char) '\0');
1256 new_appdir = malloc(alloclen);
1257
1258 if (new_appdir != NULL)
1259 {
1260 p_old = old_appdir;
1261 p_new = new_appdir;
1262 while (oldlen)
1263 {
1264 if (*p_old != '\\')
1265 {
1266 *p_new++ = *p_old;
1267 }
1268 else
1269 {
1270 *p_new++ = '\\';
1271 *p_new++ = '\\';
1272 }
1273
1274 ++p_old;
1275 --oldlen;
1276 }
1277
1278 *p_new = '\0';
1279 }
1280 }
1281 else
1282 {
1283 new_appdir = strdup(old_appdir);
1284 }
1285
1286 return new_appdir;
1287}
1288
1289static void copy_optional(void)
1290{

Callers 1

configureFunction · 0.85

Calls 4

strdupFunction · 0.85
strchrFunction · 0.50
strlenFunction · 0.50
mallocFunction · 0.50

Tested by

no test coverage detected