- .NET API: Fixed memory release problem in method

ModelNode.GetObjectReference
pull/331/head
Michael Zillgith 4 years ago
parent 7185c3b8d4
commit da08489bc3

@ -1227,16 +1227,20 @@ namespace IEC61850
/// <param name="withoutIedName">If set to <c>true</c> the object reference is created without IED name.</param>
public string GetObjectReference(bool withoutIedName = false)
{
IntPtr objRefPtr = ModelNode_getObjectReferenceEx(self, IntPtr.Zero, withoutIedName);
IntPtr nativeMemory = Marshal.AllocHGlobal(130);
IntPtr objRefPtr = ModelNode_getObjectReferenceEx(self, nativeMemory, withoutIedName);
if (objRefPtr != IntPtr.Zero) {
string objRef = Marshal.PtrToStringAnsi(objRefPtr);
Marshal.FreeHGlobal(objRefPtr);
Marshal.FreeHGlobal(nativeMemory);
return objRef;
}
else {
Marshal.FreeHGlobal(nativeMemory);
return null;
}
}

@ -49,11 +49,11 @@ namespace server_goose_publisher
{
if (cbEvent == 1)
{
Console.WriteLine("GCB " + goCB.LN.GetName() + ":" + goCB.Name + " enabled");
Console.WriteLine("GCB " + goCB.LN.GetObjectReference() + ":" + goCB.Name + " enabled");
}
else
{
Console.WriteLine("GCB " + goCB.LN.GetName() + ":" + goCB.Name + " disabled");
Console.WriteLine("GCB " + goCB.LN.GetObjectReference() + ":" + goCB.Name + " disabled");
}
}, null);

Loading…
Cancel
Save