Skip to content

Instantly share code, notes, and snippets.

@affixalex
Created July 3, 2015 05:03
Show Gist options
  • Select an option

  • Save affixalex/ea7635895250f0902b96 to your computer and use it in GitHub Desktop.

Select an option

Save affixalex/ea7635895250f0902b96 to your computer and use it in GitHub Desktop.
argv flattening
static char *create_argv_buffer(int argc, char *argv[]) {
size_t s,c = 0;
char *p;
FILE *r = open_memstream(&p, &s);
if(r==NULL) {
p=NULL;
return p;
}
while(++c<argc) {
fputs(argv[c], r);
putc(' ', r);
}
putc('\0', r);fclose(r);
return p;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment