<commit_before>#include <stdlib.h>
#include <string.h>

#include "string.h"

/**
 * checks if two strings are equal.
 * @returns 0 if the two strings are equal, otherwise nonzero
 */
int
string_equals(struct string* s1, struct string* s2)
{
    uintptr_t i;

    if (s1 == s2) return 0;
    if (s1->s == s2->s) return 0;
    if (s1->_u._s.size != s2->_u._s.size) return 1;
    
    for (i = 0; i < s1->_u._s.size; i++) if (s1->s[i] != s2->s[i]) return 1;
    return 0;
}<commit_msg>string_equals should only compare the bytes of a string that are actually used, not merely allocated<commit_after>#include <stdlib.h>
#include <string.h>

#include "string.h"

/**
 * checks if two strings are equal.
 * @returns 0 if the two strings are equal, otherwise nonzero
 */
int
string_equals(struct string* s1, struct string* s2)
{
    uintptr_t i;

    if (s1 == s2) return 0;
    if (s1->s == s2->s) return 0;
    if (s1->_u._s.length != s2->_u._s.length) return 1;
    
    for (i = 0; i < s1->_u._s.length; i++) if (s1->s[i] != s2->s[i]) return 1;
    return 0;
}
{'fraction_non_alphanumeric': 0.16367076631977295, 'fraction_numerical': 0.03405865657521287, 'mean_word_length': 3.007575757575758, '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': '7354717', 'n_tokens_mistral': 427, 'n_tokens_neox': 405, 'n_words': 133}