MCPcopy Create free account
hub / github.com/csound/csound / Insert

Method Insert

interfaces/cs_glue.cpp:559–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557 */
558
559void CsoundArgVList::Insert(int ndx, const char *s)
560{
561 char **new_argv;
562 int new_cnt, i;
563
564 if (!s)
565 return;
566 if (ndx > cnt)
567 ndx = cnt;
568 if (ndx < 0)
569 ndx = 0;
570 new_cnt = (cnt >= 0 ? cnt + 1 : 1);
571 new_argv = (char**) malloc((size_t) (new_cnt + 1) * sizeof(char*));
572 if (!new_argv)
573 return;
574 for (i = 0; i < ndx; i++)
575 new_argv[i] = ArgV_[i];
576 new_argv[i] = (char*) malloc(strlen(s) + (size_t) 1);
577 if (!new_argv[i]) {
578 free((void*) new_argv);
579 return;
580 }
581 strcpy(new_argv[i], s);
582 while (++i < new_cnt)
583 new_argv[i] = ArgV_[i - 1];
584 new_argv[i] = (char*) 0;
585 if (ArgV_)
586 free((void*) ArgV_);
587 ArgV_ = new_argv;
588 cnt = new_cnt;
589}
590
591/**
592 * Appends a new value at the end of the argument list.

Callers 1

AppendMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected