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

#include <skalibs/stralloc.h>
#include <skalibs/env.h>

int env_string (stralloc *sa, char const *const *envp, size_t envlen)
{
  size_t salen = sa->len ;
  size_t i = 0 ;
  for (; i < envlen ; i++)
  {
    if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa))
    {
      sa->len = salen ;
      return 0 ;
    }
  }
  return 1 ;
}