mirror of
https://github.com/libretro/RetroArch
synced 2025-02-02 05:54:16 +00:00
(gfx/video_coord_array.c) Cleanups
This commit is contained in:
parent
f59e334ceb
commit
1164adb902
@ -37,12 +37,9 @@ static INLINE bool realloc_checked(void **ptr, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_coord_array_resize(gfx_coord_array_t *ca,
|
static bool gfx_coord_array_resize(gfx_coord_array_t *ca,
|
||||||
unsigned count)
|
unsigned cap)
|
||||||
{
|
{
|
||||||
if (ca->coords.vertices + count >= ca->allocated)
|
size_t base_size = sizeof(float) * cap;
|
||||||
{
|
|
||||||
unsigned alloc_size = next_pow2(ca->coords.vertices + count);
|
|
||||||
size_t base_size = sizeof(float) * alloc_size;
|
|
||||||
|
|
||||||
if (!realloc_checked((void**)&ca->coords.vertex,
|
if (!realloc_checked((void**)&ca->coords.vertex,
|
||||||
2 * base_size))
|
2 * base_size))
|
||||||
@ -57,8 +54,7 @@ static bool gfx_coord_array_resize(gfx_coord_array_t *ca,
|
|||||||
2 * base_size))
|
2 * base_size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ca->allocated = alloc_size;
|
ca->allocated = cap;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,8 +65,12 @@ bool gfx_coord_array_add(gfx_coord_array_t *ca,
|
|||||||
size_t base_size, offset;
|
size_t base_size, offset;
|
||||||
count = MIN(count, coords->vertices);
|
count = MIN(count, coords->vertices);
|
||||||
|
|
||||||
if (!gfx_coord_array_resize(ca, count))
|
if (ca->coords.vertices + count >= ca->allocated)
|
||||||
|
{
|
||||||
|
unsigned cap = next_pow2(ca->coords.vertices + count);
|
||||||
|
if (!gfx_coord_array_resize(ca, cap))
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
base_size = count * sizeof(float);
|
base_size = count * sizeof(float);
|
||||||
offset = ca->coords.vertices;
|
offset = ca->coords.vertices;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user