PoeMac/C workers/percentile.c
int destroy_cm_quantile(cm_quantile *cm) {
    // Free the quantiles
    free(cm->quantiles);

    // Destroy everything in the buffer
    heap_foreach(cm->bufLess, free_buffer_sample);
    heap_destroy(cm->bufLess);
    heap_foreach(cm->bufMore, free_buffer_sample);
    heap_destroy(cm->bufMore);

    // Free the lower address, since they are allocated to be adjacent
    free((cm->bufLess < cm->bufMore) ? cm->bufLess : cm->bufMore);

    // Iterate through the linked list, free all
    cm_sample *next;
    cm_sample *current = cm->samples;
    while (current) {
        next = current->next;
        free(current);
        current = next;
    }

    return 0;
}
/**
 * Destroy the CM quantile struct.
 * @arg cm_quantile The cm_quantile to destroy
 * @return 0 on success.
 */
Destroy the CM quantile struct.
@arg cm_quantile The cm_quantile to destroy
@return 0 on success.
Destroy the CM quantile struct . @arg cm_quantile The cm_quantile to destroy @return 0 on success .
int destroy_cm_quantile(cm_quantile *cm) {
    free(cm->quantiles);
    heap_foreach(cm->bufLess, free_buffer_sample);
    heap_destroy(cm->bufLess);
    heap_foreach(cm->bufMore, free_buffer_sample);
    heap_destroy(cm->bufMore);
    free((cm->bufLess < cm->bufMore) ? cm->bufLess : cm->bufMore);
    cm_sample *next;
    cm_sample *current = cm->samples;
    while (current) {
        next = current->next;
        free(current);
        current = next;
    }
    return 0;
}
int destroy_cm_quantile ( cm_quantile * cm ) { free ( cm -> quantiles ) ; heap_foreach ( cm -> bufLess , free_buffer_sample ) ; heap_destroy ( cm -> bufLess ) ; heap_foreach ( cm -> bufMore , free_buffer_sample ) ; heap_destroy ( cm -> bufMore ) ; free ( ( cm -> bufLess < cm -> bufMore ) ? cm -> bufLess : cm -> bufMore ) ; cm_sample * next ; cm_sample * current = cm -> samples ; while ( current ) { next = current -> next ; free ( current ) ; current = next ; } return 0 ; }
Destroy the CM quantile struct.
Destroy the CM quantile struct .
// Free the quantiles // Destroy everything in the buffer // Free the lower address, since they are allocated to be adjacent // Iterate through the linked list, free all