<commit_before>/* 
 * TTBlue Class for representing Symbols
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "TTSymbol.h"
#include "TTSymbolTable.h"


/****************************************************************************************************/

TTSymbol::TTSymbol()
	: string(NULL), size(0)
{
	init("", -1);
}

TTSymbol::TTSymbol(const char* newString)
	: string(NULL), size(0)
{
	init(newString, -1);
}


TTSymbol::TTSymbol(const char* newString, TTInt32 newId)
	: string(NULL), size(0)
{
	init(newString, newId);
}


TTSymbol::~TTSymbol()
{
	delete string;
	string = NULL;
}


// Copy Constructor
TTSymbol::TTSymbol(const TTSymbol& oldSymbol)
{
	delete string; // TODO: TAP -- is this neccessary?
	id = oldSymbol.id;
	size = oldSymbol.size;
	memcpy(string, oldSymbol.string, size);
}


void TTSymbol::init(const char* newString, TTInt32 newId)<commit_msg>it's only safer if you actually alloc the memory you are using<commit_after>/* 
 * TTBlue Class for representing Symbols
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "TTSymbol.h"
#include "TTSymbolTable.h"


/****************************************************************************************************/

TTSymbol::TTSymbol()
	: string(NULL), size(0)
{
	init("", -1);
}

TTSymbol::TTSymbol(const char* newString)
	: string(NULL), size(0)
{
	init(newString, -1);
}


TTSymbol::TTSymbol(const char* newString, TTInt32 newId)
	: string(NULL), size(0)
{
	init(newString, newId);
}


TTSymbol::~TTSymbol()
{
	delete string;
	string = NULL;
}


// Copy Constructor
TTSymbol::TTSymbol(const TTSymbol& oldSymbol)
{
	delete string; // TODO: TAP -- is this neccessary?
	id = oldSymbol.id;
	size = oldSymbol.size;
	string = new char[size];
	memcpy(string, oldSymbol.string, size);
}


void TTSymbol::init(const char* newString, TTInt32 newId)
{'fraction_non_alphanumeric': 0.23427439326399208, 'fraction_numerical': 0.012877662209014363, 'mean_word_length': 4.958702064896755, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4859057', 'n_tokens_mistral': 733, 'n_tokens_neox': 666, 'n_words': 169}