[This is preliminary documentation and subject to change.]
The WinSNMP programming environment assigns the deallocation of descriptor resources to the WinSNMP implementation or the WinSNMP manager application, depending on which component allocates the memory for the descriptor.
To free the resources for an smiOID or an smiOCTETS descriptor, the following rules apply:
Because the WinSNMP manager application allocates the memory for input objects with variable lengths, the application must free that memory using an appropriate function. For example, if the application allocated the resources with a call to the GlobalAlloc function, it should use the GlobalFree function to deallocate the resources. If the application allocated the resources with a call to the HeapAlloc function, it should call the HeapFree function.
A call to any of the following functions results in the implementation allocating memory for an smiOID or an smiOCTETS descriptor: SnmpGetVb, SnmpEncodeMsg, SnmpOidCopy, SnmpContextToStr, and SnmpStrToOid.
Because the implementation allocates the memory for these output objects, the application must call the SnmpFreeDescriptor function to deallocate the resources. This function enables the implementation to free the memory allocated for the ptr member of these structures.
To free the resources for an smiVALUE structure, the following rules apply:
A WinSNMP manager application must check the syntax member of an smiVALUE structure to correctly evaluate the value member of the structure. If the syntax member indicates that the value member is an smiOCTETS or an smiOID descriptor, and the implementation allocated the resources for the descriptor, the application must call SnmpFreeDescriptor. This enables the implementation to free the memory. If the application allocated the resources, it must free the memory using an appropriate function, as indicated earlier.
For additional information, see Allocating WinSNMP Memory Objects.