Move cleanup handler elsewhere; Add sjme_alloc_copyWeak to copy data as a weak reference.
[SquirrelJME.git] / nanocoat / include / sjme / cleanup.h
blobec76cec4584d102737263e21c0ae625f4e959e39
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.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 /** Special enqueue data that represents this is an identity. */
35 #define SJME_NVM_ENQUEUE_IDENTITY ((sjme_pointer)(0x1234))
37 /**
38 * Handler for any weak references which have been enqueued.
40 * @param weak The weak reference.
41 * @param data The data for the enqueue.
42 * @param isBlockFree Is this a block free or a weak free?
43 * @return Any resultant error, if any.
44 * @since 2024/08/08
46 sjme_errorCode sjme_nvm_enqueueHandler(
47 sjme_attrInNotNull sjme_alloc_weak weak,
48 sjme_attrInNullable sjme_pointer data,
49 sjme_attrInValue sjme_jboolean isBlockFree);
51 /*--------------------------------------------------------------------------*/
53 /* Anti-C++. */
54 #ifdef __cplusplus
55 #ifdef SJME_CXX_SQUIRRELJME_CLEANUP_H
57 #undef SJME_CXX_SQUIRRELJME_CLEANUP_H
58 #undef SJME_CXX_IS_EXTERNED
59 #endif /* #ifdef SJME_CXX_SQUIRRELJME_CLEANUP_H */
60 #endif /* #ifdef __cplusplus */
62 #endif /* SQUIRRELJME_CLEANUP_H */