if (!ret)
return NULL;
- memcpy(ret, p, l);
- return ret;
+ return memcpy_safe(ret, p, l);
}
void* memdup_suffix0(const void *p, size_t l) {
if (!ret)
return NULL;
- *((uint8_t*) mempcpy(ret, p, l)) = 0;
- return ret;
+ ((uint8_t*) ret)[l] = 0;
+ return memcpy_safe(ret, p, l);
}
void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) {
size_t _l_ = l; \
assert(_l_ <= ALLOCA_MAX); \
_q_ = alloca(_l_ ?: 1); \
- memcpy(_q_, p, _l_); \
+ memcpy_safe(_q_, p, _l_); \
})
#define memdupa_suffix0(p, l) \
assert(_l_ <= ALLOCA_MAX); \
_q_ = alloca(_l_ + 1); \
((uint8_t*) _q_)[_l_] = 0; \
- memcpy(_q_, p, _l_); \
+ memcpy_safe(_q_, p, _l_); \
})
static inline void freep(void *p) {