[client] use variable-relative sizeof where possible

This commit is contained in:
Tudor Brindus
2021-08-15 12:18:22 -04:00
committed by Geoffrey McRae
parent 1c5620ba25
commit 14ad83c6b8
14 changed files with 25 additions and 25 deletions

View File

@@ -135,14 +135,14 @@ static void cursorTexFree(struct CursorTex * t)
bool egl_cursorInit(EGL_Cursor ** cursor)
{
*cursor = (EGL_Cursor *)malloc(sizeof(EGL_Cursor));
*cursor = (EGL_Cursor *)malloc(sizeof(**cursor));
if (!*cursor)
{
DEBUG_ERROR("Failed to malloc EGL_Cursor");
return false;
}
memset(*cursor, 0, sizeof(EGL_Cursor));
memset(*cursor, 0, sizeof(**cursor));
LG_LOCK_INIT((*cursor)->lock);
if (!cursorTexInit(&(*cursor)->norm,

View File

@@ -59,7 +59,7 @@ void egl_damageConfigUI(EGL_Damage * damage)
bool egl_damageInit(EGL_Damage ** damage)
{
*damage = (EGL_Damage *)malloc(sizeof(EGL_Damage));
*damage = (EGL_Damage *)malloc(sizeof(**damage));
if (!*damage)
{
DEBUG_ERROR("Failed to malloc EGL_Damage");

View File

@@ -40,14 +40,14 @@ struct EGL_DesktopRects
bool egl_desktopRectsInit(EGL_DesktopRects ** rects_, int maxCount)
{
EGL_DesktopRects * rects = malloc(sizeof(EGL_DesktopRects));
EGL_DesktopRects * rects = malloc(sizeof(*rects));
if (!rects)
{
DEBUG_ERROR("Failed to malloc EGL_DesktopRects");
return false;
}
*rects_ = rects;
memset(rects, 0, sizeof(EGL_DesktopRects));
memset(rects, 0, sizeof(*rects));
glGenVertexArrays(1, &rects->vao);
glBindVertexArray(rects->vao);

View File

@@ -25,7 +25,7 @@
void egl_drawTorus(EGL_Model * model, unsigned int pts, float x, float y,
float inner, float outer)
{
GLfloat * v = (GLfloat *)malloc(sizeof(GLfloat) * (pts + 1) * 6);
GLfloat * v = (GLfloat *)malloc(sizeof(*v) * (pts + 1) * 6);
GLfloat * dst = v;
for(unsigned int i = 0; i <= pts; ++i)
@@ -48,7 +48,7 @@ void egl_drawTorus(EGL_Model * model, unsigned int pts, float x, float y,
void egl_drawTorusArc(EGL_Model * model, unsigned int pts, float x, float y,
float inner, float outer, float s, float e)
{
GLfloat * v = (GLfloat *)malloc(sizeof(GLfloat) * (pts + 1) * 6);
GLfloat * v = (GLfloat *)malloc(sizeof(*v) * (pts + 1) * 6);
GLfloat * dst = v;
for(unsigned int i = 0; i <= pts; ++i)

View File

@@ -54,14 +54,14 @@ void update_uniform_bindings(EGL_Model * model);
bool egl_modelInit(EGL_Model ** model)
{
*model = (EGL_Model *)malloc(sizeof(EGL_Model));
*model = (EGL_Model *)malloc(sizeof(**model));
if (!*model)
{
DEBUG_ERROR("Failed to malloc EGL_Model");
return false;
}
memset(*model, 0, sizeof(EGL_Model));
memset(*model, 0, sizeof(**model));
(*model)->verticies = ll_new();
@@ -123,7 +123,7 @@ void egl_modelSetDefault(EGL_Model * model, bool flipped)
void egl_modelAddVerts(EGL_Model * model, const GLfloat * verticies, const GLfloat * uvs, const size_t count)
{
struct FloatList * fl = (struct FloatList *)malloc(sizeof(struct FloatList));
struct FloatList * fl = (struct FloatList *)malloc(sizeof(*fl));
fl->count = count;
fl->v = (GLfloat *)malloc(sizeof(GLfloat) * count * 3);

View File

@@ -51,14 +51,14 @@ struct EGL_Splash
bool egl_splashInit(EGL_Splash ** splash)
{
*splash = (EGL_Splash *)malloc(sizeof(EGL_Splash));
*splash = (EGL_Splash *)malloc(sizeof(**splash));
if (!*splash)
{
DEBUG_ERROR("Failed to malloc EGL_Splash");
return false;
}
memset(*splash, 0, sizeof(EGL_Splash));
memset(*splash, 0, sizeof(**splash));
if (!egl_shaderInit(&(*splash)->bgShader))
{