blob: 74654d02ef404ac992af850a24d7df7f98cc4fc1 (
plain) (
blame)
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
|
/* ISC license. */
#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]) ;
}
}
}
|