receiver.c 555 Bytes
Newer Older
1
#include <malloc.h>
2
#include "../util/common.h"
3 4 5 6 7 8 9
#include "../util/dbg.h"
#include "receiver.h"

PrrtReceiver *PrrtReceiver_create(const char *host, uint16_t port)
{
    PrrtReceiver *recv = calloc(1, sizeof(PrrtReceiver));
    check_mem(recv);
Andreas Schmidt's avatar
Andreas Schmidt committed
10
    recv->host_name = strdup(host);
11 12 13 14 15 16
    recv->port = port;

    return recv;

    error:
    if(recv != NULL) { free(recv); }
17
    PERROR("Memory issue.%s","");
Andreas Schmidt's avatar
Andreas Schmidt committed
18
    return NULL;
19 20 21 22 23 24 25 26
}

bool PrrtReceiver_destroy(PrrtReceiver *receiver)
{
    free((void *) receiver->host_name);
    free(receiver);
    return true;
}