---
name: "rarray_peek"
section: "3"
platform: "linux"
package: "libroy-dev"
version: "1.0.8-1"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/rarray_pop"
---

# rarray\_peek(3)

Stack like operators for Roy arrays.

Part of [rarray\_pop(3)](/rarray_pop/3.md).

## NAME

rarray\_pop, rarray\_push - Stack like operators for Roy arrays.

## SYNOPSIS

\#include \<roy.h\>

void \* rarray\_push (RArray \**array*);

void \* rarray\_pop (RArray \**array*);

void \* rarray\_peek (RArray \**array*);

## DESCRIPTION

The intention of these functions is to create a stack interface to arrays so that they may be easily used to create a stack.  This is especially useful for small entries such as a single pointer or integer where the overhead of linked lists is not needed or desired.

Due to rarray's auto-expanding behaviour, this essentially produces a stack of infinite size, while still providing good speed.

[*rarray\_push*(3)](/rarray_push/3.md) is actually a macro that directly calls [*rarray\_append*(3)](/rarray_append/3.md), but is named such so as to provide symmetry with the [*rarray\_pop*(3)](/rarray_pop/3.md) function. [*rarray\_push*(3)](/rarray_push/3.md) appends a new entry to *array*.

[*rarray\_pop*(3)](/rarray_pop/3.md) returns a pointer to the last entry in the array, and then removes it from the array.  If there are no more entries in the array, it returns NULL.

[*rarray\_peek*(3)](/rarray_peek/3.md) is actually a macro that directly calls [*rarray\_last*(3)](/rarray_last/3.md). [*rarray\_peek*(3)](/rarray_peek/3.md) returns the last entry in *array* without removing it.

## RETURN VALUE

These functions return pointers to entries in the array.  These entries must then be cast to the appropriate types as defined when created using [*rarray\_new*(3)](/rarray_new/3.md).

## ERRORS

These calls produce no errors.

## SEE ALSO

[*rarray*(3)](/rarray/3.md), [*rarray\_append*(3)](/rarray_append/3.md),  [*rarray\_free*(3)](/rarray_free/3.md), [*rarray\_last*(3)](/rarray_last/3.md),  [*rarray\_len*(3)](/rarray_len/3.md), [*rarray\_new*(3)](/rarray_new/3.md),  [*rarray\_nth*(3)](/rarray_nth/3.md), [*rarray\_peek*(3)](/rarray_peek/3.md),  [*rarray\_push*(3)](/rarray_push/3.md), [*rarray\_set\_len*(3)](/rarray_set_len/3.md),  [*roy*(3)](/roy/3.md)
