1234567891011121314151617181920212223242526272829303132 |
- // SPDX-License-Identifier: GPL-2.0 or GPL-3.0
- // Copyright © 2018-2019 Ariadne Devos
- /* shttpd - allocate task structures */
- #include "worker.h"
- #include <sHT/compiler.h>
- #include <sHT/nospec.h>
- #include <sHT/test.h>
- #include <stddef.h>
- #include <string.h>
- /* struct sHT_paper_mill is a stack structure. */
- sHT_paper
- sHT_alloc_paper(struct sHT_paper_mill *mill)
- {
- /* sHT_paper_mill is a stack structure */
- if (sHT_zero_p(mill->length))
- return NULL;
- return mill->first[sHT_index_nospec(--(mill->length), mill->capacity)];
- }
- void
- sHT_free_paper(struct sHT_paper_mill *mill, sHT_paper p)
- {
- /* From docstring: p must come from mill.
- Double-freeing is not allowed. */
- mill->first[sHT_index_nospec(mill->length++, mill->capacity)] = p;
- }
|