blob: d9d575e8232eafbe33d37d8295e692c24698e280 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/* ISC license. */
#include <skalibs/cbuffer.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <skalibs/unixmessage.h>
void unixmessage_receiver_free (unixmessage_receiver_t *b)
{
register unsigned int h = b->maindata.len ;
b->fd = -1 ;
stralloc_free(&b->maindata) ;
h = h != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ;
if (h)
{
register unsigned int n = b->auxdata.len / sizeof(int) ;
while (n--) fd_close(((int *)b->auxdata.s)[n]) ;
}
stralloc_free(&b->auxdata) ;
if (h)
{
register unsigned int n = cbuffer_len(&b->auxb) / sizeof(int) ;
if (n)
{
int fds[n] ;
cbuffer_get(&b->auxb, (char *)fds, n * sizeof(int)) ;
while (n--) fd_close(fds[n]) ;
}
}
}
|