<commit_before>// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright 2016 [bk]door.maus

#include <cassert>
#include <cstdlib>
#include <boost/functional/hash.hpp>
#include "glurg/resources/textureResource.hpp"

glurg::TextureResource::TextureResource(
	int width, int height, int depth, int level,
	int texture_type, int pixel_components, int pixel_format,
	std::uint8_t* pixels)
{
	assert(width >= 1);
	assert(height >= 1);
	assert(depth >= 1);
	assert(level >= 0);
	assert(is_valid_texture_type(texture_type));
	assert(is_valid_pixel_components(pixel_components));
	assert(is_valid_pixel_format(pixel_format));

	std::size_t pixel_size = get_pixel_size(pixel_components, pixel_format);
	std::size_t pixels_length =
		pixel_size * (std::size_t)width * (std::size_t)height * (std::size_t)depth;

	this->size = pixels_length + sizeof(TextureHeader);
	this->data = new std::uint8_t[this->size];

	this->header = (TextureHeader*)this->data;
	this->header->width = width;
	this->header->height = height;
	this->header->depth = depth;
	this->header->level = level;
	this->header->texture_type = texture_type;
	this->header->pixel_components = pixel_components;
	this->header->pixel_format = pixel_format;

	this->pixels = this->data + sizeof(TextureHeader);
	std::memcpy(this->pixels, pixels, pixels_length);

	hash = Hash::hash(this->data, this->size);
}

int glurg::TextureResource::get_width() const
{
	return this->header->width;
}

int glurg::TextureResource::get_height() const
{<commit_msg>Added missing destructor in glurg::TextureResource.<commit_after>// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright 2016 [bk]door.maus

#include <cassert>
#include <cstdlib>
#include <boost/functional/hash.hpp>
#include "glurg/resources/textureResource.hpp"

glurg::TextureResource::TextureResource(
	int width, int height, int depth, int level,
	int texture_type, int pixel_components, int pixel_format,
	std::uint8_t* pixels)
{
	assert(width >= 1);
	assert(height >= 1);
	assert(depth >= 1);
	assert(level >= 0);
	assert(is_valid_texture_type(texture_type));
	assert(is_valid_pixel_components(pixel_components));
	assert(is_valid_pixel_format(pixel_format));

	std::size_t pixel_size = get_pixel_size(pixel_components, pixel_format);
	std::size_t pixels_length =
		pixel_size * (std::size_t)width * (std::size_t)height * (std::size_t)depth;

	this->size = pixels_length + sizeof(TextureHeader);
	this->data = new std::uint8_t[this->size];

	this->header = (TextureHeader*)this->data;
	this->header->width = width;
	this->header->height = height;
	this->header->depth = depth;
	this->header->level = level;
	this->header->texture_type = texture_type;
	this->header->pixel_components = pixel_components;
	this->header->pixel_format = pixel_format;

	this->pixels = this->data + sizeof(TextureHeader);
	std::memcpy(this->pixels, pixels, pixels_length);

	hash = Hash::hash(this->data, this->size);
}

glurg::TextureResource::~TextureResource()
{
	delete[] this->data;
}

int glurg::TextureResource::get_width() const
{
	return this->header->width;
}

int glurg::TextureResource::get_height() const
{
{'fraction_non_alphanumeric': 0.14757451782583283, 'fraction_numerical': 0.008182349503214495, 'mean_word_length': 5.791666666666667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 70, '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': '3739472', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1125, 'n_words': 253}