argv__get_argv.c 585 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * argv__get_argv.c
  3. */
  4. #include <stdlib.h>
  5. #include "private.h"
  6. /*--------------------------------------------------------- */
  7. char **
  8. lub_argv__get_argv(const lub_argv_t *this, char *argv0)
  9. {
  10. char **result = NULL;
  11. unsigned i;
  12. unsigned a = 0;
  13. if(argv0)
  14. a = 1;
  15. result = malloc(sizeof(char *) * (this->argc + 1 + a));
  16. if(argv0)
  17. result[0] = argv0;
  18. for(i = 0; i < this->argc; i++)
  19. result[i + a] = this->argv[i].arg;
  20. result[i + a] = NULL;
  21. return result;
  22. }
  23. /*--------------------------------------------------------- */