cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
nishida_jp
Booster

Why Memory Reak Execute From My Function?

I'm Programing on ArchiCAD27/Windows10/VisualStudio2019C++

 

I Create Element (Object "3DText") by C++;

 

Why My Function Execute Memory Reak in ArchiCAD?

First Execute = OK

Second Execute = Memory Reak Execute!

 

GSErrCode Create3DText( API_Coord3D pos
, short floorInd
, API_AttributeIndex layer
, API_Guid& obj_guid
, char *ownUnID
, NiArchi::GlobInfo globInfo
) {
GSErrCode res = NOERROR;
API_LibPart libpart = {};
libpart.typeID = APILib_ObjectID;
strcpy(libpart.ownUnID, ownUnID);
//res = ACAPI_LibPart_Search(&libpart, false);
res = ACAPI_LibraryPart_Search(&libpart, false);
if (res == NOERROR) {
API_ParamOwnerType   paramOwner = {};
API_GetParamsType    getParams = {};
paramOwner.libInd = libpart.index;
paramOwner.type.typeID = API_ObjectID;
paramOwner.guid = APINULLGuid;
res = ACAPI_LibraryPart_OpenParameters(&paramOwner);
if (res == NOERROR) {
res = ACAPI_LibraryPart_GetActParameters(&getParams);
if (res == NOERROR) {
API_Element elem = {};
API_ElementMemo memo = {};
//Object初期値取得
elem.header.type.typeID = API_ObjectID;
res = ACAPI_Element_GetDefaults(&elem, &memo);
if (res == NOERROR) {
memo.params = getParams.params;
elem.object.libInd = libpart.index;
elem.object.xRatio = getParams.a;
elem.object.yRatio = getParams.b;
elem.object.pos.x = pos.x;
elem.object.pos.y = pos.y;
if (layer.ToInt32_Deprecated() >= 0) {
elem.header.layer = layer;
}
elem.header.floorInd = floorInd;
double z_btm = globInfo.GetFloorZpos(floorInd);
elem.object.level = pos.z - z_btm;
res = ACAPI_CallUndoableCommand(
GS::UniString("Create Object")
, [&]()->GSErrCode {
return(ACAPI_Element_Create(&elem, &memo));
});

if (res == NOERROR) {
//成功
obj_guid = elem.header.guid;
}

}//endif
ACAPI_DisposeElemMemoHdls(&memo);
}//endif

}//endif
//CLOSE
if (res == NOERROR) {
res = ACAPI_LibraryPart_CloseParameters();
}
}//endif(res)
if (res != NOERROR) {
//Error Display
}
return(res);
}

 

2 Solutions

Accepted Solutions

Have you debugged into this code to see which line triggers the fault?

Ralph Wessel BArch
Central Innovation

Go to post

nishida_jp
Booster

Thank you.

 

 

memo.params = getParams.params;

To

ACAPI_DisposeAddParHdl(&memo.params);
memo.params = getParams.params;
res = ACAPI_LibraryPart_CloseParameters();

Go to post

2 Replies 2

Have you debugged into this code to see which line triggers the fault?

Ralph Wessel BArch
Central Innovation
nishida_jp
Booster

Thank you.

 

 

memo.params = getParams.params;

To

ACAPI_DisposeAddParHdl(&memo.params);
memo.params = getParams.params;
res = ACAPI_LibraryPart_CloseParameters();

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!