libguac 1.5.5
Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef GUAC_MEM_H
21#define GUAC_MEM_H
22
31#include "private/mem.h"
32
33#include <stddef.h>
34
58#define guac_mem_alloc(...) \
59 PRIV_guac_mem_alloc( \
60 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
61 (const size_t[]) { __VA_ARGS__ } \
62 )
63
87#define guac_mem_zalloc(...) \
88 PRIV_guac_mem_zalloc( \
89 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
90 (const size_t[]) { __VA_ARGS__ } \
91 )
92
125#define guac_mem_ckd_mul(result, ...) \
126 PRIV_guac_mem_ckd_mul( \
127 result, \
128 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
129 (const size_t[]) { __VA_ARGS__ } \
130 )
131
164#define guac_mem_ckd_add(result, ...) \
165 PRIV_guac_mem_ckd_add( \
166 result, \
167 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
168 (const size_t[]) { __VA_ARGS__ } \
169 )
170
204#define guac_mem_ckd_sub(result, ...) \
205 PRIV_guac_mem_ckd_sub( \
206 result, \
207 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
208 (const size_t[]) { __VA_ARGS__ } \
209 )
210
238#define guac_mem_ckd_mul_or_die(...) \
239 PRIV_guac_mem_ckd_mul_or_die( \
240 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
241 (const size_t[]) { __VA_ARGS__ } \
242 )
243
270#define guac_mem_ckd_add_or_die(...) \
271 PRIV_guac_mem_ckd_add_or_die( \
272 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
273 (const size_t[]) { __VA_ARGS__ } \
274 )
275
303#define guac_mem_ckd_sub_or_die(...) \
304 PRIV_guac_mem_ckd_sub_or_die( \
305 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
306 (const size_t[]) { __VA_ARGS__ } \
307 )
308
340#define guac_mem_realloc(mem, ...) \
341 PRIV_guac_mem_realloc( \
342 mem, \
343 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
344 (const size_t[]) { __VA_ARGS__ } \
345 )
346
377#define guac_mem_realloc_or_die(mem, ...) \
378 PRIV_guac_mem_realloc_or_die( \
379 mem, \
380 sizeof((const size_t[]) { __VA_ARGS__ }) / sizeof(const size_t), \
381 (const size_t[]) { __VA_ARGS__ } \
382 )
383
394#define guac_mem_free(mem) (PRIV_guac_mem_free(mem), (mem) = NULL, (void) 0)
395
410#define guac_mem_free_const(mem) PRIV_guac_mem_free((void*) (mem))
411
412#endif
413