src/timestamp.c
author Volker Birk <vb@pep.foundation>
Thu, 01 Sep 2016 17:55:03 +0200
branchkeysync
changeset 1111 3c46dc58096d
parent 125 5119178815d8
child 1513 e7f7e42385b5
permissions -rw-r--r--
merging
     1 #include "pEp_internal.h"
     2 
     3 #include "timestamp.h"
     4 
     5 #include <stdlib.h>
     6 #include <string.h>
     7 #include <assert.h>
     8 
     9 DYNAMIC_API timestamp * new_timestamp(time_t clock)
    10 {
    11     timestamp *ts = calloc(1, sizeof(timestamp));
    12     assert(ts);
    13     if (ts == NULL)
    14         return NULL;
    15 
    16     if (clock)
    17         gmtime_r(&clock, ts);
    18 
    19     return ts;
    20 }
    21 
    22 
    23 DYNAMIC_API void free_timestamp(timestamp *ts)
    24 {
    25     free(ts);
    26 }
    27 
    28 DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
    29 {
    30     timestamp *dst = malloc(sizeof(timestamp));
    31     assert(dst);
    32     if (dst == NULL)
    33         return NULL;
    34 
    35     memcpy(dst, src, sizeof(timestamp));
    36     return dst;
    37 }
    38