MCPcopy Create free account
hub / github.com/Kitware/VTK / pj_trim_argv

Function pj_trim_argv

ThirdParty/libproj/vtklibproj/src/internal.cpp:319–352  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

317
318/*****************************************************************************/
319char **pj_trim_argv (size_t argc, char *args) {
320/******************************************************************************
321Create an argv-style array from elements placed in the argument string, args.
322
323args is a trimmed string as returned by pj_trim_argc(), and argc is the number
324of trimmed strings found (i.e. the return value of pj_trim_args()). Hence,
325 int argc = pj_trim_argc (args);
326 char **argv = pj_trim_argv (argc, args);
327will produce a classic style (argc, argv) pair from a string of whitespace
328separated args. No new memory is allocated for storing the individual args
329(they stay in the args string), but for the pointers to the args a new array
330is allocated and returned.
331
332It is the duty of the caller to free this array.
333******************************************************************************/
334
335 if (nullptr==args)
336 return nullptr;
337 if (0==argc)
338 return nullptr;
339
340
341 /* turn the input string into an array of strings */
342 char** argv = (char **) calloc (argc, sizeof (char *));
343 if (nullptr==argv)
344 return nullptr;
345 for(size_t i = 0, j = 0; j < argc; j++) {
346 argv[j] = args + i;
347 char* str = argv[j];
348 size_t nLen = strlen(str);
349 i += nLen + 1;
350 }
351 return argv;
352}
353
354
355/*****************************************************************************/

Callers 1

pj_create_internalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected