Example #1
0
static void
test_qes_free(void *ptr)
{
    char *dat = strdup("test");

    (void) ptr;
    /* Test freeing buffer */
    tt_ptr_op(dat, !=, NULL);
    qes_free(dat);
    tt_ptr_op(dat, ==, NULL);
    /* This free(NULL) should not fail */
    qes_free(dat);
    tt_ptr_op(dat, ==, NULL);
end:
    if (dat != NULL) free(dat);
}
Example #2
0
struct qes_seqfile *
qes_seqfile_create (const char *path, const char *mode)
{
    struct qes_seqfile *sf = NULL;
    if (path == NULL || mode == NULL) return NULL;
    sf = qes_calloc(1, sizeof(*sf));
    sf->qf = qes_file_open(path, mode);
    if (sf->qf == NULL) {
        qes_free(sf->qf);
        qes_free(sf);
        return NULL;
    }
    qes_str_init(&sf->scratch, __INIT_LINE_LEN);
    sf->n_records = 0;
    qes_seqfile_guess_format(sf);
    return sf;
}
Example #3
0
void
qes_seqfile_destroy_(struct qes_seqfile *seqfile)
{
    if (seqfile != NULL) {
        qes_file_close(seqfile->qf);
        qes_str_destroy_cp(&seqfile->scratch);
        qes_free(seqfile);
    }
}
Example #4
0
/*===  FUNCTION  ============================================================*
Name:           qes_seq_destroy
Paramters:      struct qes_seq *: seq to destroy.
Description:    Deallocate and set to NULL a struct qes_seq on the heap.
Returns:        void.
 *===========================================================================*/
void
qes_seq_destroy_ (struct qes_seq *seq)
{
    if (seq != NULL) {
        qes_str_destroy_cp(&seq->name);
        qes_str_destroy_cp(&seq->comment);
        qes_str_destroy_cp(&seq->seq);
        qes_str_destroy_cp(&seq->qual);
        qes_free(seq);
    }
}
Example #5
0
void
qes_str_destroy (struct qes_str *str)
{
    qes_str_destroy_cp(str);
    qes_free(str);
}
Example #6
0
void
qes_str_destroy_cp (struct qes_str *str)
{
    if (str != NULL) qes_free(str->str);
}