<commit_before>#include "StdAfx.h"
#include "ParticleReadData.h"
//#include <PxParticleReadData.h> 

ParticleReadData::ParticleReadData(PxParticleReadData* data)
	: LockedData(data)
{
}

void ParticleReadData::Unlock()
{
	this->UnmanagedPointer->unlock();
}

array<int>^ ParticleReadData::GetValidParticleBitmap()
{
	if (this->UnmanagedPointer->validParticleRange == 0)
		return nullptr;

	return Util::AsManagedArray<int>(this->UnmanagedPointer->validParticleBitmap, this->UnmanagedPointer->validParticleRange - 1);
}

array<Vector3>^ ParticleReadData::GetPositions()
{
	const int n = this->UnmanagedPointer->nbValidParticles;

	if (n <= 0)
		return nullptr;

	PxVec3 *p =  (PxVec3 *) malloc(n * sizeof(PxVec3));

	p = new PxVec3[n];

	for (int i = 0; i < n; i++)
		p[i] = this->UnmanagedPointer->positionBuffer[i];

	array<Vector3>^ ret = Util::AsManagedArray<Vector3>((void*)p, n);

	free(p);

	return ret;
}
<commit_msg>Fix #6 ParticleReadData GetPositions memory leak<commit_after>#include "StdAfx.h"
#include "ParticleReadData.h"
//#include <PxParticleReadData.h> 

ParticleReadData::ParticleReadData(PxParticleReadData* data)
	: LockedData(data)
{
}

void ParticleReadData::Unlock()
{
	this->UnmanagedPointer->unlock();
}

array<int>^ ParticleReadData::GetValidParticleBitmap()
{
	if (this->UnmanagedPointer->validParticleRange == 0)
		return nullptr;

	return Util::AsManagedArray<int>(this->UnmanagedPointer->validParticleBitmap, this->UnmanagedPointer->validParticleRange - 1);
}

array<Vector3>^ ParticleReadData::GetPositions()
{
	const int n = this->UnmanagedPointer->nbValidParticles;

	if (n <= 0)
		return nullptr;

	const PxVec3* p = this->UnmanagedPointer->positionBuffer.ptr();

	auto positions = Util::AsManagedArray<Vector3>(p, n);

	return positions;
}

{'fraction_non_alphanumeric': 0.14816901408450706, 'fraction_numerical': 0.010140845070422535, 'mean_word_length': 6.52542372881356, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 38, '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': '5102800', 'n_tokens_mistral': 655, 'n_tokens_neox': 626, 'n_words': 107}