somAllocate
This method supports class-specific memory allocation for class instances. It cannot be overridden.
For backward compatibility, this method does not take an Environment parameter.
Syntax
SOMClass receiver; long size; string rc; rc = somAllocate(receiver, size);
Parameters
- receiver (SOMClass)
- A pointer to the class object whose memory allocation method is desired.
- size (long)
- The number of bytes to be allocated.
Return Code
- rc (string)
string A pointer to the first byte of the allocated memory region. NULL If sufficient memory is not available.
Remarks
When building a class, the somBuildClass function is responsible for registering the procedure that will be executed when this method is invoked on the class. The default procedure registered by somBuildClass uses the SOMMalloc function, but the IDL odifier somallocate can be used in the SOM IDL class implementation section to indicate a different procedure. Users of this method should be sure to use the dual method, somDeallocate, to free allocated storage. Also, if the IDL modifier somallocate is used to indicate a special allocation routine, the IDL modifier somdeallocate should be used to indicate a dual procedure to be called when the somDeallocate method is invoked.
Example Code
#include <som.xh> #<somcls.xh> main() { SOMClassMgr *cm = somEnvironmentNew(); /* Use SOMClass's instance allocation method */ string newRegion = _SOMClass->somAllocate(20); }
Related
Methods
- somDeallocate