forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from 6d634674a9..73d9b845a3
73d9b845a3 cleanup: Remove old type-ordered event getters. b0840cc02d feat: add ngc events 7df9a51349 refactor: Make event dispatch ordered by receive time. bcb6592af5 test: Add C++ classes wrapping system interfaces. 4cea4f9ca4 fix: Make all the fuzzers work again, and add a test for protodump. c4e209ea1d refactor: Factor out malloc+memcpy into memdup. 87bcc4322d fix: Remove fatal error for non-erroneous case REVERT: 6d634674a9 cleanup: Remove old type-ordered event getters. REVERT: d1d48d1dfc feat: add ngc events REVERT: 994ffecc6b refactor: Make event dispatch ordered by receive time. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 73d9b845a310c3f56d2d6d77ed56b93d84256d6e
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ccompat.h"
|
||||
@ -80,6 +81,21 @@ bool memeq(const uint8_t *a, size_t a_size, const uint8_t *b, size_t b_size)
|
||||
return a_size == b_size && memcmp(a, b, a_size) == 0;
|
||||
}
|
||||
|
||||
uint8_t *memdup(const uint8_t *data, size_t data_size)
|
||||
{
|
||||
if (data == nullptr || data_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t *copy = (uint8_t *)malloc(data_size);
|
||||
|
||||
if (copy != nullptr) {
|
||||
memcpy(copy, data, data_size);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
int16_t max_s16(int16_t a, int16_t b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
|
Reference in New Issue
Block a user