skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

envalloc_merge.c (605B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/bytestr.h>
      4 #include <skalibs/env.h>
      5 #include <skalibs/genalloc.h>
      6 #include <skalibs/envalloc.h>
      7 
      8 int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
      9 {
     10   size_t modifn = byte_count(modifs, modiflen, '\0') ;
     11   size_t n = envlen + 1 + modifn ;
     12   if (!genalloc_readyplus(char const *, v, n)) return 0 ;
     13   n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, modifn) ;
     14   genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ;
     15   return 1 ;
     16 }