summaryrefslogtreecommitdiffstats
path: root/lib/isc/include/isc/astack.h
blob: a4f6762259f49fc55c6e789a9d5a643e1946c2b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#pragma once

#include <inttypes.h>

#include <isc/mem.h>
#include <isc/types.h>

isc_astack_t *
isc_astack_new(isc_mem_t *mctx, size_t size);
/*%<
 * Allocate and initialize a new array stack of size 'size'.
 */

void
isc_astack_destroy(isc_astack_t *stack);
/*%<
 * Free an array stack 'stack'.
 *
 * Requires:
 * \li	'stack' is empty.
 */

bool
isc_astack_trypush(isc_astack_t *stack, void *obj);
/*%<
 * Try to push 'obj' onto array stack 'astack'. On failure, either
 * because the stack size limit has been reached or because another
 * thread has already changed the stack pointer, return 'false'.
 */

void *
isc_astack_pop(isc_astack_t *stack);
/*%<
 * Pop an object off of array stack 'stack'. If the stack is empty,
 * return NULL.
 */