1-74 SOMobjects Base Toolkit: Programmer’s Reference Manual
somAllocate Method
Purpose
Supports class-specific memory allocation for class instances. Cannot be overridden.
IDL Syntax
string somAllocate (in long size);
Note: For backward compatibility, this method does not take an Environment parameter.
Description
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
modifier 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.
Parameters
receiver A pointer to the class object whose memory allocation method is desired.
size The number of bytes to be allocated.
Return Value
string A pointer to the first byte of the allocated memory region, or NULL if
sufficient memory is not available.
C++ Example
#include <som.xh>
#include <somcls.xh>
main()
{
SOMClassMgr *cm = somEnvironmentNew();
/* Use SOMClass’s instance allocation method */
string newRegion = _SOMClass–>somAllocate(20);
}
Original Class
SOMClass
Related Information
Methods: somDeallocate
Komentarze do niniejszej Instrukcji