src/timestamp.c
author Volker Birk <vb@pep-project.org>
Wed, 25 Mar 2015 12:55:15 +0100
changeset 124 e2930c783d3c
child 125 5119178815d8
permissions -rw-r--r--
adding timestamp
     1 #include "timestamp.h"
     2 
     3 #include <stdlib.h>
     4 #include <string.h>
     5 #include <assert.h>
     6 
     7 DYNAMIC_API timestamp * new_timestamp(time_t clock)
     8 {
     9     timestamp *ts = calloc(1, sizeof(timestamp));
    10     assert(ts);
    11     if (ts == NULL)
    12         return NULL;
    13 
    14     if (clock)
    15         gmtime_r(&clock, ts);
    16 
    17     return ts;
    18 }
    19 
    20 
    21 DYNAMIC_API void free_timestamp(timestamp *ts)
    22 {
    23     free(ts);
    24 }
    25 
    26 DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
    27 {
    28     timestamp *dst = malloc(sizeof(timestamp));
    29     assert(dst);
    30     if (dst == NULL)
    31         return NULL;
    32 
    33     memcpy(dst, src, sizeof(timestamp));
    34     return dst;
    35 }
    36