Files
tomato-testing/toxcore/tox_memory_impl.h
Green Sky 596ea37298 Squashed 'external/toxcore/c-toxcore/' changes from 640e6cace..e58eb27a8
e58eb27a8 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff.
206ea3530 refactor: Explicitly pass dependencies to constructors.
7cefa93cf fix(toxencryptsave): Wipe salt and passkey after usage.
7c3be2342 refactor: Add file/line to tox-bootstrapd logging.
f84e8cdce refactor: Move loglogdata out of network.c.
390f7db06 refactor: Move random and memory OS-specifics to `os_*` files.
REVERT: 640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: e58eb27a84f9fa0cd996868e079f39e90a5c04b6
2025-11-04 21:18:05 +01:00

50 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013 Tox project.
*/
/**
* Datatypes, functions and includes for the core networking.
*/
#ifndef C_TOXCORE_TOXCORE_TOX_MEMORY_IMPL_H
#define C_TOXCORE_TOXCORE_TOX_MEMORY_IMPL_H
#include <stdint.h> // uint*_t
#include "tox_memory.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Allocate a byte array, similar to malloc. */
typedef void *tox_memory_malloc_cb(void *self, uint32_t size);
/** @brief Reallocate a byte array, similar to realloc. */
typedef void *tox_memory_realloc_cb(void *self, void *ptr, uint32_t size);
/**
* @brief Deallocate a byte or object array, similar to free.
*
* Note that `tox_memory_free` will use this callback to deallocate itself, so
* once the deallocation is done, the allocator data structures can no longer be
* referenced.
*/
typedef void tox_memory_dealloc_cb(void *self, void *ptr);
/** @brief Functions wrapping standard C memory allocation functions. */
struct Tox_Memory_Funcs {
tox_memory_malloc_cb *malloc_callback;
tox_memory_realloc_cb *realloc_callback;
tox_memory_dealloc_cb *dealloc_callback;
};
struct Tox_Memory {
const Tox_Memory_Funcs *funcs;
void *user_data;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* C_TOXCORE_TOXCORE_TOX_MEMORY_IMPL_H */