mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed memory leaks
This commit is contained in:
parent
29fbafb91f
commit
2ac6b339b2
4 changed files with 51 additions and 15 deletions
|
@ -398,6 +398,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~Dictionary()
|
~Dictionary()
|
||||||
|
{
|
||||||
|
DeleteData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AllocData(intptr size, Entry*& outEntries, int_cosize*& outBuckets)
|
||||||
|
{
|
||||||
|
uint8* data = new uint8[size * (sizeof(Entry) + sizeof(int_cosize))];
|
||||||
|
outEntries = (Entry*)data;
|
||||||
|
outBuckets = (int_cosize*)(data + size * sizeof(Entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteData()
|
||||||
{
|
{
|
||||||
if (!std::is_pod<TKey>::value)
|
if (!std::is_pod<TKey>::value)
|
||||||
{
|
{
|
||||||
|
@ -417,18 +429,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AllocData(intptr size, Entry*& outEntries, int_cosize*& outBuckets)
|
|
||||||
{
|
|
||||||
uint8* data = new uint8[size * (sizeof(Entry) + sizeof(int_cosize))];
|
|
||||||
outEntries = (Entry*)data;
|
|
||||||
outBuckets = (int_cosize*)(data + size * sizeof(Entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteData()
|
|
||||||
{
|
|
||||||
delete mEntries;
|
delete mEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ BfGenericExtensionEntry* BfModule::BuildGenericExtensionInfo(BfGenericTypeInstan
|
||||||
{
|
{
|
||||||
auto genericParamInstance = new BfGenericTypeParamInstance(partialTypeDef, paramIdx);
|
auto genericParamInstance = new BfGenericTypeParamInstance(partialTypeDef, paramIdx);
|
||||||
genericParamInstance->mExternType = GetGenericParamType(BfGenericParamKind_Type, paramIdx);
|
genericParamInstance->mExternType = GetGenericParamType(BfGenericParamKind_Type, paramIdx);
|
||||||
|
|
||||||
|
auto prevPtr = genericExEntry->mGenericParams.mVals;
|
||||||
genericExEntry->mGenericParams.push_back(genericParamInstance);
|
genericExEntry->mGenericParams.push_back(genericParamInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +963,8 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
||||||
}
|
}
|
||||||
resolvedTypeRef->mDefineState = BfTypeDefineState_DefinedAndMethodsSlotted;
|
resolvedTypeRef->mDefineState = BfTypeDefineState_DefinedAndMethodsSlotted;
|
||||||
resolvedTypeRef->mRebuildFlags = BfTypeRebuildFlag_None;
|
resolvedTypeRef->mRebuildFlags = BfTypeRebuildFlag_None;
|
||||||
typeAlias->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, BfAttributeTargets_Alias);
|
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL))
|
||||||
|
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, BfAttributeTargets_Alias);
|
||||||
|
|
||||||
// Fall through so generic params are populated in DoPopulateType
|
// Fall through so generic params are populated in DoPopulateType
|
||||||
}
|
}
|
||||||
|
|
|
@ -1587,7 +1587,8 @@ BfGenericTypeInstance::~BfGenericTypeInstance()
|
||||||
{
|
{
|
||||||
for (auto genericParamInstance : mGenericParams)
|
for (auto genericParamInstance : mGenericParams)
|
||||||
genericParamInstance->Release();
|
genericParamInstance->Release();
|
||||||
delete mGenericExtensionInfo;
|
if (mGenericExtensionInfo != NULL)
|
||||||
|
delete mGenericExtensionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfGenericTypeInstance::GenericParamsVector* BfGenericTypeInstance::GetGenericParamsVector(BfTypeDef* declaringTypeDef)
|
BfGenericTypeInstance::GenericParamsVector* BfGenericTypeInstance::GetGenericParamsVector(BfTypeDef* declaringTypeDef)
|
||||||
|
|
|
@ -1749,6 +1749,38 @@ public:
|
||||||
virtual void ReportMemory(MemReporter* memReporter) override;
|
virtual void ReportMemory(MemReporter* memReporter) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class LogAlloc
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
T* allocate(intptr count)
|
||||||
|
{
|
||||||
|
auto ptr = (T*)malloc(sizeof(T) * count);
|
||||||
|
OutputDebugStrF("LogAlloc.allocate: %p\n", ptr);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(T* ptr)
|
||||||
|
{
|
||||||
|
OutputDebugStrF("LogAlloc.deallocate: %p\n", ptr);
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* rawAllocate(intptr size)
|
||||||
|
{
|
||||||
|
auto ptr = malloc(size);
|
||||||
|
OutputDebugStrF("LogAlloc.rawAllocate: %p\n", ptr);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rawDeallocate(void* ptr)
|
||||||
|
{
|
||||||
|
OutputDebugStrF("LogAlloc.rawFree: %p\n", ptr);
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class BfBoxedType : public BfTypeInstance
|
class BfBoxedType : public BfTypeInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue