src/siri/db/points.c
/*
 * Returns a copy of points or NULL in case of an error. NULL is also returned
 * if points is NULL.
 */
Returns a copy of points or NULL in case of an error. NULL is also returned
if points is NULL.
Returns a copy of points or NULL in case of an error . NULL is also returned if points is NULL .
siridb_points_t * siridb_points_copy(siridb_points_t * points)
{
    if (points == NULL)
    {
        return NULL;
    }
    siridb_points_t * cpoints =
            (siridb_points_t *) malloc(sizeof(siridb_points_t));
    if (cpoints != NULL)
    {
        size_t sz = sizeof(siridb_point_t) * points->len;
        cpoints->len = points->len;
        cpoints->tp = points->tp;
        cpoints->content = NULL;
        cpoints->data = (siridb_point_t *) malloc(sz);
        if (cpoints->data == NULL)
        {
            free(cpoints);
            cpoints = NULL;
        }
        else
        {
            memcpy(cpoints->data, points->data, sz);
        }
    }
    return cpoints;
}
siridb_points_t * siridb_points_copy ( siridb_points_t * points ) { if ( points == NULL ) { return NULL ; } siridb_points_t * cpoints = ( siridb_points_t * ) malloc ( sizeof ( siridb_points_t ) ) ; if ( cpoints != NULL ) { size_t sz = sizeof ( siridb_point_t ) * points -> len ; cpoints -> len = points -> len ; cpoints -> tp = points -> tp ; cpoints -> content = NULL ; cpoints -> data = ( siridb_point_t * ) malloc ( sz ) ; if ( cpoints -> data == NULL ) { free ( cpoints ) ; cpoints = NULL ; } else { memcpy ( cpoints -> data , points -> data , sz ) ; } } return cpoints ; }
Returns a copy of points or NULL in case of an error.
Returns a copy of points or NULL in case of an error .