Back to index

glibc  2.9
argz-create.c File Reference
#include <argz.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.


error_t __argz_create (char *const argv[], char **argz, size_t *len)

Function Documentation

error_t __argz_create ( char *const  argv[],
char **  argz,
size_t len 

Definition at line 29 of file argz-create.c.

  int argc;
  size_t tlen = 0;
  char *const *ap;
  char *p;

  for (argc = 0; argv[argc] != NULL; ++argc)
    tlen += strlen (argv[argc]) + 1;

  if (tlen == 0)
    *argz = NULL;
      *argz = malloc (tlen);
      if (*argz == NULL)
       return ENOMEM;

      for (p = *argz, ap = argv; *ap; ++ap, ++p)
       p = __stpcpy (p, *ap);
  *len = tlen;

  return 0;

Here is the call graph for this function:

Here is the caller graph for this function: