<commit_before>/**
 * @file      token_bucket.c
 * @brief     Token bucket implementation.
 * @author    <NAME>
 * @date      27 May 2016
 * @copyright Copyright 2016 <NAME>. All rights reserved.
 *            This project is released under the MIT license.
 */

#include "logger.h"
#include "token_bucket.h"
#include "util_date.h"
#include "util_unit.h"

/**
 * @see See header file for interface comments.
 */
bool tokenbucket_init(struct tokenbucket * const tb, const uint64_t rate)
{
    bool retval = false;

    if (tb == NULL)
    {
        logger_printf(LOGGER_LEVEL_ERROR,
                      "%s: parameter validation failed\n",
                      __FUNCTION__);
    }
    else
    {
        tb->rate = rate;
        tb->size = rate;
        tb->tsus = utildate_gettstime(DATE_CLOCK_MONOTONIC, UNIT_TIME_USEC);

        retval = true;
    };
<commit_msg>token_bucket: set initial bucket size to zero<commit_after>/**
 * @file      token_bucket.c
 * @brief     Token bucket implementation.
 * @author    <NAME>
 * @date      27 May 2016
 * @copyright Copyright 2016 <NAME>. All rights reserved.
 *            This project is released under the MIT license.
 */

#include "logger.h"
#include "token_bucket.h"
#include "util_date.h"
#include "util_unit.h"

/**
 * @see See header file for interface comments.
 */
bool tokenbucket_init(struct tokenbucket * const tb, const uint64_t rate)
{
    bool retval = false;

    if (tb == NULL)
    {
        logger_printf(LOGGER_LEVEL_ERROR,
                      "%s: parameter validation failed\n",
                      __FUNCTION__);
    }
    else
    {
        tb->rate = rate;
        tb->size = 0;
        tb->tsus = utildate_gettstime(DATE_CLOCK_MONOTONIC, UNIT_TIME_USEC);

        retval = true;
    };

{'fraction_non_alphanumeric': 0.10809281267685342, 'fraction_numerical': 0.014148273910582909, 'mean_word_length': 2.2801484230055657, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '3054468', 'n_tokens_mistral': 569, 'n_tokens_neox': 543, 'n_words': 152}