src/timestamp.c
author Roker <roker@pep-project.org>
Tue, 20 Sep 2016 15:54:57 +0200
branchroker-linux
changeset 1168 4d4e3ecbaf8b
parent 125 5119178815d8
child 1513 e7f7e42385b5
permissions -rw-r--r--
merge "default" into my branch
vb@125
     1
#include "pEp_internal.h"
vb@125
     2
vb@124
     3
#include "timestamp.h"
vb@124
     4
vb@124
     5
#include <stdlib.h>
vb@124
     6
#include <string.h>
vb@124
     7
#include <assert.h>
vb@124
     8
vb@124
     9
DYNAMIC_API timestamp * new_timestamp(time_t clock)
vb@124
    10
{
vb@124
    11
    timestamp *ts = calloc(1, sizeof(timestamp));
vb@124
    12
    assert(ts);
vb@124
    13
    if (ts == NULL)
vb@124
    14
        return NULL;
vb@124
    15
vb@124
    16
    if (clock)
vb@124
    17
        gmtime_r(&clock, ts);
vb@124
    18
vb@124
    19
    return ts;
vb@124
    20
}
vb@124
    21
vb@124
    22
vb@124
    23
DYNAMIC_API void free_timestamp(timestamp *ts)
vb@124
    24
{
vb@124
    25
    free(ts);
vb@124
    26
}
vb@124
    27
vb@124
    28
DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
vb@124
    29
{
vb@124
    30
    timestamp *dst = malloc(sizeof(timestamp));
vb@124
    31
    assert(dst);
vb@124
    32
    if (dst == NULL)
vb@124
    33
        return NULL;
vb@124
    34
vb@124
    35
    memcpy(dst, src, sizeof(timestamp));
vb@124
    36
    return dst;
vb@124
    37
}
vb@124
    38