<commit_before>/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
/* For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt */

#include "util.h"
#include "datastack.h"

#define STACK_DELTA    100

int
DataStack_init(Stats *pstats, DataStack *pdata_stack)
{
    pdata_stack->depth = -1;
    pdata_stack->stack = NULL;
    pdata_stack->alloc = 0;
    return RET_OK;
}

void
DataStack_dealloc(Stats *pstats, DataStack *pdata_stack)
{
    PyMem_Free(pdata_stack->stack);
}

int
DataStack_grow(Stats *pstats, DataStack *pdata_stack)
{
    pdata_stack->depth++;
    if (pdata_stack->depth >= pdata_stack->alloc) {
        STATS( pstats->stack_reallocs++; )
        /* We've outgrown our data_stack array: make it bigger. */
        int bigger = pdata_stack->alloc + STACK_DELTA;
        DataStackEntry * bigger_data_stack = PyMem_Realloc(pdata_stack->stack, bigger * sizeof(DataStackEntry));
        if (bigger_data_stack == NULL) {
            PyErr_NoMemory();
            pdata_stack->depth--;
            return RET_ERROR;
        }
        pdata_stack->stack = bigger_data_stack;
        pdata_stack->alloc = bigger;
    }<commit_msg>If STATS is enabled, all STATS() have to be after declarations<commit_after>/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
/* For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt */

#include "util.h"
#include "datastack.h"

#define STACK_DELTA    100

int
DataStack_init(Stats *pstats, DataStack *pdata_stack)
{
    pdata_stack->depth = -1;
    pdata_stack->stack = NULL;
    pdata_stack->alloc = 0;
    return RET_OK;
}

void
DataStack_dealloc(Stats *pstats, DataStack *pdata_stack)
{
    PyMem_Free(pdata_stack->stack);
}

int
DataStack_grow(Stats *pstats, DataStack *pdata_stack)
{
    pdata_stack->depth++;
    if (pdata_stack->depth >= pdata_stack->alloc) {
        /* We've outgrown our data_stack array: make it bigger. */
        int bigger = pdata_stack->alloc + STACK_DELTA;
        DataStackEntry * bigger_data_stack = PyMem_Realloc(pdata_stack->stack, bigger * sizeof(DataStackEntry));
        STATS( pstats->stack_reallocs++; )
        if (bigger_data_stack == NULL) {
            PyErr_NoMemory();
            pdata_stack->depth--;
            return RET_ERROR;
        }
        pdata_stack->stack = bigger_data_stack;
        pdata_stack->alloc = bigger;
    }
{'fraction_non_alphanumeric': 0.1236047953699876, 'fraction_numerical': 0.005787515502273667, 'mean_word_length': 3.194107452339688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6173160', 'n_tokens_mistral': 822, 'n_tokens_neox': 817, 'n_words': 160}