[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

@@ -216,7 +216,7 @@ void app_clipboardRequest(const LG_ClipboardReplyFn replyFn, void * opaque)
if (!g_params.clipboardToLocal)
return;
struct CBRequest * cbr = (struct CBRequest *)malloc(sizeof(struct CBRequest));
struct CBRequest * cbr = (struct CBRequest *)malloc(sizeof(*cbr));
cbr->type = g_state.cbType;
cbr->replyFn = replyFn;
@@ -658,7 +658,7 @@ KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque, con
return NULL;
}
KeybindHandle handle = (KeybindHandle)malloc(sizeof(struct KeybindHandle));
KeybindHandle handle = (KeybindHandle)malloc(sizeof(*handle));
handle->sc = sc;
handle->callback = callback;
handle->opaque = opaque;
@@ -711,7 +711,7 @@ void app_registerOverlay(const struct LG_OverlayOps * ops, const void * params)
{
ASSERT_LG_OVERLAY_VALID(ops);
struct Overlay * overlay = malloc(sizeof(struct Overlay));
struct Overlay * overlay = malloc(sizeof(*overlay));
overlay->ops = ops;
overlay->params = params;
overlay->udata = NULL;

View File

@@ -41,7 +41,7 @@ struct ll
struct ll * ll_new(void)
{
struct ll * list = malloc(sizeof(struct ll));
struct ll * list = malloc(sizeof(*list));
list->head = NULL;
list->tail = NULL;
list->pos = NULL;
@@ -61,7 +61,7 @@ void ll_free(struct ll * list)
void ll_push(struct ll * list, void * data)
{
struct ll_item * item = malloc(sizeof(struct ll_item));
struct ll_item * item = malloc(sizeof(*item));
item->data = data;
item->next = NULL;

View File

@@ -198,7 +198,7 @@ struct LG_OverlayOps LGOverlayGraphs =
GraphHandle overlayGraph_register(const char * name, RingBuffer buffer, float min, float max)
{
struct OverlayGraph * graph = malloc(sizeof(struct OverlayGraph));
struct OverlayGraph * graph = malloc(sizeof(*graph));
graph->name = name;
graph->buffer = buffer;
graph->enabled = true;