MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / exchange

Function exchange

lib/getopt.c:221–242  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

219 the new indices of the non-options in ARGV after they are moved. */
220
221static void
222exchange(argv)
223char **argv;
224{
225 int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *);
226 char **temp = (char **) calloc(1, nonopts_size);
227
228 /* Interchange the two blocks of data in ARGV. */
229
230 my_bcopy((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
231 my_bcopy((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
232 (optind - last_nonopt) * sizeof(char *));
233 my_bcopy((char *) temp,
234 (char *) &argv[first_nonopt + optind - last_nonopt],
235 nonopts_size);
236
237 /* Update records for the slots the non-options now occupy. */
238
239 first_nonopt += (optind - last_nonopt);
240 last_nonopt = optind;
241 free(temp);
242}
243
244/* Scan elements of ARGV (whose length is ARGC) for option characters
245 given in OPTSTRING.

Callers 1

_getopt_internalFunction · 0.85

Calls 1

my_bcopyFunction · 0.85

Tested by

no test coverage detected