MCPcopy Create free account
hub / github.com/Kitware/CMake / kwsysSystem__AppendArgument

Function kwsysSystem__AppendArgument

Source/kwsys/System.c:50–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50static int kwsysSystem__AppendArgument(char** local, char*** begin,
51 char*** end, int* size, char* arg_local,
52 char** arg_begin, char** arg_end,
53 int* arg_size)
54{
55 /* Append a null-terminator to the argument string. */
56 if (!kwsysSystem__AppendByte(arg_local, arg_begin, arg_end, arg_size,
57 '\0')) {
58 return 0;
59 }
60
61 /* Allocate space for the argument pointer. */
62 if ((*end - *begin) >= *size) {
63 kwsysSystem_ptrdiff_t length = *end - *begin;
64 char** newPointers = (char**)malloc((size_t)(*size) * 2 * sizeof(char*));
65 if (!newPointers) {
66 return 0;
67 }
68 memcpy(newPointers, *begin, (size_t)(length) * sizeof(char*));
69 if (*begin != local) {
70 free(*begin);
71 }
72 *begin = newPointers;
73 *end = *begin + length;
74 *size *= 2;
75 }
76
77 /* Allocate space for the argument string. */
78 **end = (char*)malloc((size_t)(*arg_end - *arg_begin));
79 if (!**end) {
80 return 0;
81 }
82
83 /* Store the argument in the command array. */
84 memcpy(**end, *arg_begin, (size_t)(*arg_end - *arg_begin));
85 ++(*end);
86
87 /* Reset the argument to be empty. */
88 *arg_end = *arg_begin;
89
90 return 1;
91}
92
93#define KWSYSPE_LOCAL_BYTE_COUNT 1024
94#define KWSYSPE_LOCAL_ARGS_COUNT 32

Callers 1

Calls 1

kwsysSystem__AppendByteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…