mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
3c5d27e3e9
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
27 lines
563 B
C
27 lines
563 B
C
#include "config.h"
|
|
#include <assert.h>
|
|
#include <lightningd/peer_fd.h>
|
|
#include <unistd.h>
|
|
|
|
static void destroy_peer_fd(struct peer_fd *peer_fd)
|
|
{
|
|
if (peer_fd->fd != -1)
|
|
close(peer_fd->fd);
|
|
}
|
|
|
|
struct peer_fd *new_peer_fd(const tal_t *ctx, int peer_fdnum)
|
|
{
|
|
struct peer_fd *peer_fd = tal(ctx, struct peer_fd);
|
|
|
|
peer_fd->fd = peer_fdnum;
|
|
tal_add_destructor(peer_fd, destroy_peer_fd);
|
|
return peer_fd;
|
|
}
|
|
|
|
struct peer_fd *new_peer_fd_arr(const tal_t *ctx, const int *fd)
|
|
{
|
|
/* We expect 1 fd. */
|
|
assert(tal_count(fd) == 1);
|
|
return new_peer_fd(ctx, fd[0]);
|
|
}
|