<commit_before>/* 
 * Jamoma TTNode Tree
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "NodeLib.h"

TTTreePtr jamoma_tree = NULL;

/***********************************************************************************
*
*		C EXTERN METHODS
*
************************************************************************************/

// Method to deal with the jamoma tree
/////////////////////////////////////////

TTTreePtr	jamoma_tree_init()
{
	if(jamoma_tree)
		return jamoma_tree;	// already have a tree, just return the pointer to the tree...

	jamoma_tree = new TTTree(TT("Jamoma"));

	return jamoma_tree;
}

JamomaError jamoma_tree_free(void)
{
	if(jamoma_tree){
		jamoma_tree->~TTTree();
		return JAMOMA_ERR_NONE;
	}
	
	post("jamoma_tree_free : create a tree before");	
	return JAMOMA_ERR_GENERIC;
}

JamomaError jamoma_tree_dump(void)
{
	unsigned int i;
	TTValue *hk;
	TTSymbolPtr key;

	if(jamoma_tree){	
		hk = new TTValue();
		jamoma_tree->getDirectory()->getKeys(*hk);

		for(i=0; i<jamoma_tree->getDirectory()->getSize(); i++){
			hk->get(i,(TTSymbol**)&key);
			post("%s",key->getCString());
		}
		return JAMOMA_ERR_NONE;
	}
	
	post("jamoma_tree_dump : create a tree before");
	return JAMOMA_ERR_GENERIC;
}

JamomaError	jamoma_tree_register(t_symbol *OSCaddress, t_symbol *type, t_object *obj, TTNodePtr *newNode, bool *newInstanceCreated)<commit_msg>NodeLib: fixed memory leak in jamoma_tree_dump().  The 'new TTValue' was not matched by a 'delete TTValue'.  I changed from allocating off the heap to allocating the TTValue on the stack, which consequently means we don't have to explicitly free it.<commit_after>/* 
 * Jamoma TTNode Tree
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "NodeLib.h"

TTTreePtr jamoma_tree = NULL;

/***********************************************************************************
*
*		C EXTERN METHODS
*
************************************************************************************/

// Method to deal with the jamoma tree
/////////////////////////////////////////

TTTreePtr	jamoma_tree_init()
{
	if(jamoma_tree)
		return jamoma_tree;	// already have a tree, just return the pointer to the tree...

	jamoma_tree = new TTTree(TT("Jamoma"));

	return jamoma_tree;
}

JamomaError jamoma_tree_free(void)
{
	if(jamoma_tree){
		jamoma_tree->~TTTree();
		return JAMOMA_ERR_NONE;
	}
	
	post("jamoma_tree_free : create a tree before");	
	return JAMOMA_ERR_GENERIC;
}

JamomaError jamoma_tree_dump(void)
{
	unsigned int i;
	TTValue hk;
	TTSymbolPtr key;

	if(jamoma_tree){	
		jamoma_tree->getDirectory()->getKeys(hk);

		for(i=0; i<jamoma_tree->getDirectory()->getSize(); i++){
			hk.get(i,(TTSymbol**)&key);
			post("%s",key->getCString());
		}
		return JAMOMA_ERR_NONE;
	}
	
	post("jamoma_tree_dump : create a tree before");
	return JAMOMA_ERR_GENERIC;
}

JamomaError	jamoma_tree_register(t_symbol *OSCaddress, t_symbol *type, t_object *obj, TTNodePtr *newNode, bool *newInstanceCreated)
{'fraction_non_alphanumeric': 0.23991102637432477, 'fraction_numerical': 0.0031776294884016524, 'mean_word_length': 4.493891797556719, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '1200492', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1021, 'n_words': 253}