Created
July 3, 2015 05:03
-
-
Save affixalex/ea7635895250f0902b96 to your computer and use it in GitHub Desktop.
argv flattening
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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