skalibs

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

unixmessage_sender_free.c (646B)


      1 /* ISC license. */
      2 
      3 #include <sys/types.h>
      4 #include <skalibs/disize.h>
      5 #include <skalibs/stralloc.h>
      6 #include <skalibs/genalloc.h>
      7 #include <skalibs/djbunix.h>
      8 #include <skalibs/unixmessage.h>
      9 
     10 void unixmessage_sender_free (unixmessage_sender *b)
     11 {
     12   size_t n = genalloc_len(int, &b->fds) ;
     13   if (n)
     14   {
     15     size_t i = genalloc_s(disize, &b->offsets)[b->head].right ;
     16     for (; i < n ; i++)
     17     {
     18       int fd = genalloc_s(int, &b->fds)[i] ;
     19       if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ;
     20     }
     21   }
     22   genalloc_free(disize, &b->offsets) ;
     23   genalloc_free(int, &b->fds) ;
     24   stralloc_free(&b->data) ;
     25   *b = unixmessage_sender_zero ;
     26 }