Jump to content

SomFree: Difference between revisions

From EDM2
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:somFree (SOMObject)}}
{{DISPLAYTITLE:somFree}}
 
'''Note:''' Some further explanation is needed to don't confuse [[somFree]] function with this somFree SOMObject method.
 
This method releases the storage used by an object. Intended for use by object clients. Not generally overridden.
This method releases the storage used by an object. Intended for use by object clients. Not generally overridden.


For backward compatibility, this method does not take an Environment parameter.
For backward compatibility, this method does not take an Environment parameter.


; Original Class : [[SOMObject]]
;Original Class : [[SOMObject]]


==Syntax==
==Syntax==
<PRE>
void somFree (SOMObject receiver)
void somFree (SOMObject receiver)
</PRE>


==Parameters==
==Parameters==
; receiver (SOMObject) : A pointer to the object to be freed.
;receiver ([[SOMObject]]) - input
:A pointer to the object to be freed.


==Return Code==
==Return Code==
Line 21: Line 17:


==Remarks==
==Remarks==
The somFree method releases the storage containing the receiver object by calling the method somDeallocate. No future references should be made to the receiver once this is done. The somFree method calls somDestruct to allow storage pointed to by the object to be freed.
The somFree method releases the storage containing the receiver object by calling the method [[somDeallocate]]. No future references should be made to the receiver once this is done. The somFree method calls [[somDestruct]] to allow storage pointed to by the object to be freed.


The somFree method should not be called on objects created by somRenew, thus the method is normally only used by code that also created the object.
The somFree method should not be called on objects created by [[somRenew]], thus the method is normally only used by code that also created the object.


'''Note:''' SOM also supplies a macro, SOMFree, which is used to free a block of memory. This macro should not be used on objects.
;Note: SOM also supplies a macro, [[SOMFree]], which is used to free a block of memory. This macro should not be used on objects.


==Example Code==
==Example Code==
Line 47: Line 43:


==Related==
==Related==
===Functions===
;Functions
* SOMFree
* [[SOMFree]]
===Methods===
;Methods
* somNew
* [[somNew]]
* somNewNoInit
* [[somNewNoInit]]
* somDestruct  
* [[somDestruct]]


[[Category:SOMObject]]
[[Category:SOM method]]

Latest revision as of 15:40, 7 April 2024

This method releases the storage used by an object. Intended for use by object clients. Not generally overridden.

For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMObject

Syntax

void somFree (SOMObject receiver)

Parameters

receiver (SOMObject) - input
A pointer to the object to be freed.

Return Code

rc

Remarks

The somFree method releases the storage containing the receiver object by calling the method somDeallocate. No future references should be made to the receiver once this is done. The somFree method calls somDestruct to allow storage pointed to by the object to be freed.

The somFree method should not be called on objects created by somRenew, thus the method is normally only used by code that also created the object.

Note
SOM also supplies a macro, SOMFree, which is used to free a block of memory. This macro should not be used on objects.

Example Code

#include <animal.h>

void main()
{
   Animal myAnimal;
   /*
    * Create an object.
    */
   myAnimal = AnimalNew();

   /* ... */

   /* Free it when finished. */
   _somFree(myAnimal);
}

Related

Functions
Methods