summaryrefslogtreecommitdiff
path: root/src/libstddjb/env_make.c
blob: 60148f863edaeb2422b46c59143fe6dae8bf333e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <string.h>
#include <errno.h>
#include <skalibs/env.h>

int env_make (char const **v, size_t argc, char const *s, size_t len)
{
  while (argc--)
  {
    size_t n = strlen(s) + 1 ;
    if (n > len) return (errno = EINVAL, 0) ;
    *v++ = s ; s += n ; len -= n ;
  }
  return 1 ;
}