forked from Green-Sky/tomato
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
65 lines
1.3 KiB
C
65 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-3.0-or-later
|
|
* Copyright © 2016-2025 The TokTok team.
|
|
* Copyright © 2013 Tox project.
|
|
*/
|
|
|
|
#include "mem.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include "ccompat.h"
|
|
#include "tox_memory.h"
|
|
|
|
void *mem_balloc(const Memory *mem, uint32_t size)
|
|
{
|
|
void *const ptr = tox_memory_malloc(mem, size);
|
|
return ptr;
|
|
}
|
|
|
|
void *mem_brealloc(const Memory *mem, void *ptr, uint32_t size)
|
|
{
|
|
void *const new_ptr = tox_memory_realloc(mem, ptr, size);
|
|
return new_ptr;
|
|
}
|
|
|
|
void *mem_alloc(const Memory *mem, uint32_t size)
|
|
{
|
|
void *const ptr = tox_memory_malloc(mem, size);
|
|
if (ptr != nullptr) {
|
|
memset(ptr, 0, size);
|
|
}
|
|
return ptr;
|
|
}
|
|
|
|
void *mem_valloc(const Memory *mem, uint32_t nmemb, uint32_t size)
|
|
{
|
|
const uint32_t bytes = nmemb * size;
|
|
|
|
if (size != 0 && bytes / size != nmemb) {
|
|
return nullptr;
|
|
}
|
|
|
|
void *const ptr = tox_memory_malloc(mem, bytes);
|
|
if (ptr != nullptr) {
|
|
memset(ptr, 0, bytes);
|
|
}
|
|
return ptr;
|
|
}
|
|
|
|
void *mem_vrealloc(const Memory *mem, void *ptr, uint32_t nmemb, uint32_t size)
|
|
{
|
|
const uint32_t bytes = nmemb * size;
|
|
|
|
if (size != 0 && bytes / size != nmemb) {
|
|
return nullptr;
|
|
}
|
|
|
|
void *const new_ptr = tox_memory_realloc(mem, ptr, bytes);
|
|
return new_ptr;
|
|
}
|
|
|
|
void mem_delete(const Memory *mem, void *ptr)
|
|
{
|
|
tox_memory_dealloc(mem, ptr);
|
|
}
|