Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (H-K)
Guardian Procedure Calls Reference Manual522629-013
7-7
HEAPSORT Procedure
size-of-element input
INT:value
is the size, in words, of each element in
array.
compare-proc input
INT PROC
is an application-supplied function procedure that HEAPSORT calls to determine
the sorted order (ascending or descending) of the elements in
array.
This procedure must be of the form:
INT PROC compare-proc ( element-a , element-b );
INT .element-a;
INT .element-b;
The compare-proc must compare element-a with element-b and return
either of the following values:
0 (indicating false) if
element-b should precede element-a
1 (indicating true) if element-a should precede element-b
element-a and element-b are INT:ref parameters.
Considerations
In addition to its local variables, HEAPSORT allocates stack space equal to the
value you specify as the size of one array element. If insufficient stack space is
available, the call to HEAPSORT fails: a TNS Guardian process gets a stack
overflow trap; an OSS or native process receives a SIGSTK signal.
Example
In the following example, HEAPSORT sorts the elements in array in ascending order.
CALL HEAPSORT ( array, num^elements, element^size,
ascending );