<commit_before>/**
  @file str.c
  @brief See header for details
  $Revision$
  $HeadURL$
*/
#include "str.h"
#include <assert.h>

/* Forward declare our struct */
struct str_t {
    size_t size;
    char data[];
};

str_t* str_new(const char* p_cstr)
{
    str_t* p_str = NULL;
    size_t len   = 0;
    assert(NULL != p_cstr);
    len   = strlen(p_cstr);
    p_str = (str_t*)mem_allocate(sizeof(str_t) + len + 1, NULL);
    p_str->size = len;
    memcpy(p_str->data, p_cstr, len+1);
    return p_str;
}

size_t str_size(str_t* p_str)
{
    assert(NULL != p_str);
    return p_str->size;
}

const char* str_cstr(str_t* p_str)
{
    assert(NULL != p_str);
    return p_str->data;
}

str_t* str_copy(str_t* p_str)
{
    str_t* p_newstr;
    assert(NULL != p_str);
    p_newstr = (str_t*)mem_allocate(sizeof(str_t) + p_str->size + 1, NULL);
    memcpy(p_newstr->data, p_str->data, p_str->size+1);
    p_newstr->size = p_str->size;
    return p_newstr;
}

char str_at(str_t* p_str, size_t index)
{
    assert(NULL != p_str);
    return (index >= p_str->size) ? '\0' : p_str->data[index];
}

str_t* str_set(str_t* p_str, size_t index, char val)
{
    (void)p_str;
    (void)index;
    (void)val;
    return NULL;
}

str_t* str_concat(str_t* p_str1, str_t* p_str2)
{
    (void)p_str1;
    (void)p_str2;
    return NULL;
}

str_t* str_insert(str_t* p_str1, size_t index, str_t* p_str2)
{
    (void)p_str1;
    (void)index;
    (void)p_str2;<commit_msg>Implemented str_set<commit_after>/**
  @file str.c
  @brief See header for details
  $Revision$
  $HeadURL$
*/
#include "str.h"
#include <assert.h>

/* Forward declare our struct */
struct str_t {
    size_t size;
    char data[];
};

str_t* str_new(const char* p_cstr)
{
    str_t* p_str = NULL;
    size_t len   = 0;
    assert(NULL != p_cstr);
    len   = strlen(p_cstr);
    p_str = (str_t*)mem_allocate(sizeof(str_t) + len + 1, NULL);
    p_str->size = len;
    memcpy(p_str->data, p_cstr, len+1);
    return p_str;
}

size_t str_size(str_t* p_str)
{
    assert(NULL != p_str);
    return p_str->size;
}

const char* str_cstr(str_t* p_str)
{
    assert(NULL != p_str);
    return p_str->data;
}

str_t* str_copy(str_t* p_str)
{
    str_t* p_newstr;
    assert(NULL != p_str);
    p_newstr = (str_t*)mem_allocate(sizeof(str_t) + p_str->size + 1, NULL);
    memcpy(p_newstr->data, p_str->data, p_str->size+1);
    p_newstr->size = p_str->size;
    return p_newstr;
}

char str_at(str_t* p_str, size_t index)
{
    assert(NULL != p_str);
    return (index >= p_str->size) ? '\0' : p_str->data[index];
}

str_t* str_set(str_t* p_str, size_t index, char val)
{
    str_t* p_newstr = NULL;
    assert(NULL != p_str);
    if (index < p_str->size)
    {
        p_newstr = str_copy(p_str);
        p_newstr->data[index] = val;
    }
    return p_newstr;
}

str_t* str_concat(str_t* p_str1, str_t* p_str2)
{
    (void)p_str1;
    (void)p_str2;
    return NULL;
}

str_t* str_insert(str_t* p_str1, size_t index, str_t* p_str2)
{
    (void)p_str1;
    (void)index;
    (void)p_str2;
{'fraction_non_alphanumeric': 0.15684976836532097, 'fraction_numerical': 0.009265387160820648, 'mean_word_length': 3.2457865168539324, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 33, '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': '2838974', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1361, 'n_words': 263}