<commit_before>#include "sc_arraytex.h"
#include "sc_strbuf.h"
#include "sc_list.h"
#include "sc_path.h"
#include "sc_imaging.h"
#include "sc_math.h"

#define TARGET GL_TEXTURE_2D_ARRAY
#define ASSERT_FINALIZED(X) assert(X->texture)
#define ASSERT_NOT_FINALIZED(X) assert(!X->texture)

struct _sc_arraytex {
    size_t width;
    size_t height;
    size_t slices;
    GLenum format;
    sc_strbuf_t **buffers;
    sc_list_t *textures;
    sc_texture_t *texture;
    int flags;
    size_t mipmap_levels;
};

sc_arraytex_t *
sc_new_arraytex(size_t width, size_t height, int flags)
{
    int i;
    sc_arraytex_t *rv = sc_xalloc(sc_arraytex_t);
    /* because we do not support resizing of textures we have to ensure
       that what we create here is a power of two */
    assert(sc_is_power_of_two(width));
    assert(sc_is_power_of_two(height));
    rv->width = width;
    rv->height = height;
    rv->slices = 0;
    rv->texture = NULL;
        
    /* XXX: nearest neighbour mipmap generation appears broken on windows.
        this might be caused by wrong mipmap levels, a memory corruption
        in the algorithm or unexpected pitch. */
#if SC_PLATFORM != SC_PLATFORM_WINDOWS
    if (flags & SC_ARRAYTEX_MIPMAPS && flags & SC_ARRAYTEX_NEAREST
        rv->mipmap_levels = sc_intlog2(sc_max(width, height)) + 1;
    else
        rv->mipmap_levels = 1;
#else
    rv->mipmap_levels = 1;
#endif

    rv->buffers = sc_xmalloc(sizeof(sc_strbuf_t *) * rv->mipmap_levels);
    for (i = 0; i < rv->mipmap_levels; i++)
        rv->buffers[i] = sc_new_strbuf();
    rv->textures = sc_new_list();
    rv->flags = flags;
    return rv;
}

void
sc_free_arraytex(sc_arraytex_t *arr)
{
    int i;
    if (!arr)
        return;
    for (i = 0; i < arr->textures->size; i++)
        sc_free(arr->textures->items[i]);<commit_msg>Fixed typo introduced when fixing the windows version<commit_after>#include "sc_arraytex.h"
#include "sc_strbuf.h"
#include "sc_list.h"
#include "sc_path.h"
#include "sc_imaging.h"
#include "sc_math.h"

#define TARGET GL_TEXTURE_2D_ARRAY
#define ASSERT_FINALIZED(X) assert(X->texture)
#define ASSERT_NOT_FINALIZED(X) assert(!X->texture)

struct _sc_arraytex {
    size_t width;
    size_t height;
    size_t slices;
    GLenum format;
    sc_strbuf_t **buffers;
    sc_list_t *textures;
    sc_texture_t *texture;
    int flags;
    size_t mipmap_levels;
};

sc_arraytex_t *
sc_new_arraytex(size_t width, size_t height, int flags)
{
    int i;
    sc_arraytex_t *rv = sc_xalloc(sc_arraytex_t);
    /* because we do not support resizing of textures we have to ensure
       that what we create here is a power of two */
    assert(sc_is_power_of_two(width));
    assert(sc_is_power_of_two(height));
    rv->width = width;
    rv->height = height;
    rv->slices = 0;
    rv->texture = NULL;
        
    /* XXX: nearest neighbour mipmap generation appears broken on windows.
        this might be caused by wrong mipmap levels, a memory corruption
        in the algorithm or unexpected pitch. */
#if SC_PLATFORM != SC_PLATFORM_WINDOWS
    if (flags & SC_ARRAYTEX_MIPMAPS && flags & SC_ARRAYTEX_NEAREST)
        rv->mipmap_levels = sc_intlog2(sc_max(width, height)) + 1;
    else
        rv->mipmap_levels = 1;
#else
    rv->mipmap_levels = 1;
#endif

    rv->buffers = sc_xmalloc(sizeof(sc_strbuf_t *) * rv->mipmap_levels);
    for (i = 0; i < rv->mipmap_levels; i++)
        rv->buffers[i] = sc_new_strbuf();
    rv->textures = sc_new_list();
    rv->flags = flags;
    return rv;
}

void
sc_free_arraytex(sc_arraytex_t *arr)
{
    int i;
    if (!arr)
        return;
    for (i = 0; i < arr->textures->size; i++)
        sc_free(arr->textures->items[i]);
{'fraction_non_alphanumeric': 0.11407568744895182, 'fraction_numerical': 0.004356112169888375, 'mean_word_length': 3.312206572769953, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, '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': '863226', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1365, 'n_words': 330}