You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
1.2 KiB

name: duk_check_stack_top
proto: |
duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);
summary: |
<p>Like <code><a href="#duk_check_stack">duk_check_stack()</a></code>,
but ensures there is space up to <code>top</code> for caller's use.
This is sometimes more convenient than specifying the number of
additional elements (relative to current stack top) to reserve.</p>
<div class="note">
The caller specifies the maximum stack top ensured for caller's
use, not the highest value stack index reserved for the caller.
For instance, if <code>top</code> is 500, the highest value stack
index reserved for the caller is 499.
</div>
<p>As a general rule
<code><a href="#duk_require_stack_top">duk_require_stack_top()</a></code> should be
used instead of this function to reserve more stack space. If value stack
cannot be extended, there is almost never a useful recovery strategy except
to throw an error and unwind.</p>
example: |
if (duk_check_stack_top(ctx, 100)) {
printf("value stack guaranteed up to index 99\n");
} else {
printf("cannot get value stack space\n");
}
tags:
- stack
seealso:
- duk_require_stack_top
introduced: 1.0.0