<commit_before>/**
 * Copyright (c) 2015, <NAME> (hit9 <<EMAIL>>)
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "todo.h"

/**
 * New task.
 */
task_t *
task_new(int state, uint8_t *data, size_t size)
{
    task_t *task = malloc(sizeof(task_t));

    if (task != NULL) {
        task->state = state;
        task->next = NULL;

        hbuf_t *data = hbuf_new(TODO_BUF_UNIT);

        if (!data)
            return NULL

        task->data = data;
    }
    return task;
}

/**
 * Free task.
 */
void
task_free(task_t *task)
{
    if (task != NULL) {
        if (task->data != NULL)
            hbuf_free(task->data);
        free(task);
    }
}

/**
 * New todo.
 */
todo_t *
todo_new()
{
    todo_t *todo = malloc(sizeof(todo_t));

    if (todo != NULL) {
        todo->head = NULL;
    }
    return todo;
}<commit_msg>Fix task_new<commit_after>/**
 * Copyright (c) 2015, <NAME> (hit9 <<EMAIL>>)
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "todo.h"

/**
 * New task.
 */
task_t *
task_new(int state, uint8_t *data, size_t size)
{
    task_t *task = malloc(sizeof(task_t));

    if (task != NULL) {
        task->state = state;
        task->next = NULL;

        hbuf_t *buf = hbuf_new(TODO_BUF_UNIT);

        if (!buf)
            return NULL;

        if (hbuf_put(buf, data, size) != HBUF_OK)
            return NULL;

        task->data = buf;
    }
    return task;
}

/**
 * Free task.
 */
void
task_free(task_t *task)
{
    if (task != NULL) {
        if (task->data != NULL)
            hbuf_free(task->data);
        free(task);
    }
}

/**
 * New todo.
 */
todo_t *
todo_new()
{
    todo_t *todo = malloc(sizeof(todo_t));

    if (todo != NULL) {
        todo->head = NULL;
    }
    return todo;
}
{'fraction_non_alphanumeric': 0.10814290312198262, 'fraction_numerical': 0.0038622465400708077, 'mean_word_length': 2.7221556886227547, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3332920', 'n_tokens_mistral': 1028, 'n_tokens_neox': 965, 'n_words': 362}