Allow closeable and nvm structures to be located by where they were allocated.
[SquirrelJME.git] / nanocoat / include / sjme / cleanup.h
blob5d53331c515a282c0c82d9865e08f3e179905365
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Cleaning functions.
13 * @since 2024/08/09
16 #ifndef SQUIRRELJME_CLEANUP_H
17 #define SQUIRRELJME_CLEANUP_H
19 #include "sjme/nvm/nvm.h"
20 #include "sjme/alloc.h"
22 /* Anti-C++. */
23 #ifdef __cplusplus
24 #ifndef SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_IS_EXTERNED
26 #define SJME_CXX_SQUIRRELJME_CLEANUP_H
27 extern "C"
29 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
30 #endif /* #ifdef __cplusplus */
32 /*--------------------------------------------------------------------------*/
34 /**
35 * Allocates virtual machine structure type.
37 * @param inPool The pool to allocate within.
38 * @param allocSize The allocation size.
39 * @param inType The type of structure this is.
40 * @param outCommon The resultant common structure.
41 * @return On any resultant error, if any.
42 * @since 2024/09/28
44 sjme_errorCode sjme_nvm_allocR(
45 sjme_attrInNotNull sjme_alloc_pool* inPool,
46 sjme_attrInPositiveNonZero sjme_jint allocSize,
47 sjme_attrInValue sjme_nvm_structType inType,
48 sjme_attrOutNotNull sjme_nvm_common* outCommon
49 SJME_DEBUG_ONLY_COMMA SJME_DEBUG_DECL_FILE_LINE_FUNC_OPTIONAL);
51 /**
52 * Allocates virtual machine structure type.
54 * @param inPool The pool to allocate within.
55 * @param allocSize The allocation size.
56 * @param inType The type of structure this is.
57 * @param outCommon The resultant common structure.
58 * @return On any resultant error, if any.
59 * @since 2024/09/29
61 #define sjme_nvm_alloc(inPool, allocSize, refCounting, outCommon) \
62 (sjme_nvm_allocR((inPool), (allocSize), (refCounting), \
63 (outCommon) SJME_DEBUG_ONLY_COMMA SJME_DEBUG_FILE_LINE_FUNC_OPTIONAL))
65 /*--------------------------------------------------------------------------*/
67 /* Anti-C++. */
68 #ifdef __cplusplus
69 #ifdef SJME_CXX_SQUIRRELJME_CLEANUP_H
71 #undef SJME_CXX_SQUIRRELJME_CLEANUP_H
72 #undef SJME_CXX_IS_EXTERNED
73 #endif /* #ifdef SJME_CXX_SQUIRRELJME_CLEANUP_H */
74 #endif /* #ifdef __cplusplus */
76 #endif /* SQUIRRELJME_CLEANUP_H */