Simplify MALLOC invocations

Remove overload for C array decay, and fix up the call sites that
required it.
This commit is contained in:
Kp 2021-06-28 03:37:48 +00:00
parent b918d33e1c
commit ee07a45712
4 changed files with 4 additions and 10 deletions

View file

@ -52,7 +52,7 @@ void gr_set_bitmap_data(grs_bitmap &bm, const uint8_t *data)
grs_bitmap_ptr gr_create_bitmap(uint16_t w, uint16_t h )
{
RAIIdmem<uint8_t[]> d;
MALLOC(d, unsigned char, MAX_BMP_SIZE(w, h));
MALLOC(d, uint8_t[], MAX_BMP_SIZE(w, h));
return gr_create_bitmap_raw(w, h, std::move(d));
}
@ -91,7 +91,7 @@ void gr_init_main_bitmap(grs_main_bitmap &bm, const bm_mode mode, const uint16_t
void gr_init_bitmap_alloc(grs_main_bitmap &bm, const bm_mode mode, const uint16_t x, const uint16_t y, const uint16_t w, const uint16_t h, const uint16_t bytesperline)
{
RAIIdmem<uint8_t[]> d;
MALLOC(d, unsigned char, MAX_BMP_SIZE(w, h));
MALLOC(d, uint8_t[], MAX_BMP_SIZE(w, h));
gr_init_main_bitmap(bm, mode, x, y, w, h, bytesperline, std::move(d));
}

View file

@ -158,12 +158,6 @@ RAIIdmem<T> &MALLOC(RAIIdmem<T> &r, std::size_t count, const char *var, const ch
return r.reset(MALLOC<typename RAIIdmem<T>::element_type>(p, count, var, file, line)), r;
}
template <typename T>
RAIIdmem<T[]> &MALLOC(RAIIdmem<T[]> &r, const std::size_t count, const char *const var, const char *const file, const unsigned line)
{
return MALLOC<T[]>(r, count, var, file, line);
}
template <typename T>
void CALLOC(RAIIdmem<T> &r, std::size_t count, const char *var, const char *file, unsigned line)
{

View file

@ -508,7 +508,7 @@ static void ogl_init_font(grs_font * font)
{
RAIIdmem<uint8_t[]> data;
const unsigned length = tw * th;
MALLOC(data, uint8_t, length);
MALLOC(data, uint8_t[], length);
std::fill_n(data.get(), length, TRANSPARENCY_COLOR); // map the whole data with transparency so we won't have borders if using gap
gr_init_main_bitmap(font->ft_parent_bitmap, bm_mode::linear, 0, 0, tw, th, tw, std::move(data));
}

View file

@ -5617,7 +5617,7 @@ void init_hoard_data(d_vclip_array &Vclip)
return;
const unsigned extent = icon_w * icon_h;
RAIIdmem<uint8_t[]> bitmap_data2;
MALLOC(bitmap_data2, uint8_t, extent);
MALLOC(bitmap_data2, uint8_t[], extent);
PHYSFS_read(ifile,&palette[0],sizeof(palette[0]),palette.size());
PHYSFS_read(ifile, bitmap_data2.get(), 1, extent);
gr_init_main_bitmap(i, bm_mode::linear, 0, 0, icon_w, icon_h, icon_w, std::move(bitmap_data2));