You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
678 B
C
21 lines
678 B
C
// 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/.
|
|
|
|
#pragma once
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "scoped.h"
|
|
#include "typecheck.h"
|
|
|
|
static inline void _tlsl_mem_free(void **p) {
|
|
free(*p);
|
|
}
|
|
|
|
DEF_SCOPED_TYPE(mem, void *, NULL, _tlsl_mem_free)
|
|
|
|
#define MEM_SCOPED(TYPE, VAL) SCOPED(mem, TYPE *, VAL)
|
|
#define MEM_FREE(TYPE, MEM) ({ TLSL_CHECK_TYPE(TYPE **, MEM), (TYPE *)_scoped_mem_cleanup((void **)(MEM)); })
|
|
#define MEM_RELEASE(TYPE, MEM) ({ TLSL_CHECK_TYPE(TYPE **, MEM), (TYPE *)_scoped_mem_release((void **)(MEM)); })
|