Cleanup: remove sprintf use in guarded allocator

Also remove vsprintf in exr_printf (commented out).
This commit is contained in:
Campbell Barton 2023-06-27 15:27:34 +10:00
parent 3c6239969e
commit d27be2b95d
2 changed files with 7 additions and 6 deletions

@ -261,14 +261,17 @@ void *MEM_guarded_dupallocN(const void *vmemh)
#else
{
MemHead *nmemh;
char *name = malloc(strlen(memh->name) + 24);
const char name_prefix[] = "dupli_alloc ";
const size_t name_prefix_len = sizeof(name_prefix) - 1;
const size_t name_size = strlen(memh->name) + 1;
char *name = malloc(name_prefix_len + name_size);
memcpy(name, name_prefix, sizeof(name_prefix));
memcpy(name + name_prefix_len, memh->name, name_size);
if (LIKELY(memh->alignment == 0)) {
sprintf(name, "%s %s", "dupli_alloc", memh->name);
newp = MEM_guarded_mallocN(memh->len, name);
}
else {
sprintf(name, "%s %s", "dupli_alloc", memh->name);
newp = MEM_guarded_mallocN_aligned(memh->len, (size_t)memh->alignment, name);
}

@ -1758,12 +1758,10 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
static void exr_printf(const char *fmt, ...)
{
#if 0
char output[1024];
va_list args;
va_start(args, fmt);
std::vsprintf(output, fmt, args);
vprintf(fmt, args);
va_end(args);
printf("%s", output);
#else
(void)fmt;
#endif