From 392b2e0b6c8979b712b47eee91c4cb4b0d086983 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 24 Jun 2021 09:50:13 -0700 Subject: [PATCH] Made custom allocators work with pointers to structs, give proper errors --- IDEHelper/Compiler/BfModule.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index c652d5ba..66ef6ff4 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -8375,7 +8375,17 @@ BfIRValue BfModule::AllocBytes(BfAstNode* refNode, const BfAllocTarget& allocTar else if (allocTarget.mCustomAllocator) { auto customTypeInst = allocTarget.mCustomAllocator.mType->ToTypeInstance(); - if (customTypeInst != NULL) + if (customTypeInst == NULL) + { + if (allocTarget.mCustomAllocator.mType->IsStructPtr()) + customTypeInst = allocTarget.mCustomAllocator.mType->GetUnderlyingType()->ToTypeInstance(); + } + + if (customTypeInst == NULL) + { + Fail(StrFormat("Type '%s' cannot be used as a custom allocator", TypeToString(allocTarget.mCustomAllocator.mType).c_str()), refNode); + } + else { BfTypedValueExpression typeValueExpr; String allocMethodName = "Alloc";