src/timestamp.c
author Krista Bennett <krista@pep-project.org>
Fri, 01 Jun 2018 10:30:19 +0200
branchENGINE-233
changeset 2727 b8b0443804da
parent 1513 e7f7e42385b5
child 2381 c01f2e8f3582
permissions -rw-r--r--
close branch
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #include "pEp_internal.h"
     5 
     6 #include "timestamp.h"
     7 
     8 #include <stdlib.h>
     9 #include <string.h>
    10 #include <assert.h>
    11 
    12 DYNAMIC_API timestamp * new_timestamp(time_t clock)
    13 {
    14     timestamp *ts = calloc(1, sizeof(timestamp));
    15     assert(ts);
    16     if (ts == NULL)
    17         return NULL;
    18 
    19     if (clock)
    20         gmtime_r(&clock, ts);
    21 
    22     return ts;
    23 }
    24 
    25 
    26 DYNAMIC_API void free_timestamp(timestamp *ts)
    27 {
    28     free(ts);
    29 }
    30 
    31 DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
    32 {
    33     timestamp *dst = malloc(sizeof(timestamp));
    34     assert(dst);
    35     if (dst == NULL)
    36         return NULL;
    37 
    38     memcpy(dst, src, sizeof(timestamp));
    39     return dst;
    40 }
    41