diff --git a/client/displayservers/Wayland/clipboard.c b/client/displayservers/Wayland/clipboard.c index d7872410..7c4a4a8c 100644 --- a/client/displayservers/Wayland/clipboard.c +++ b/client/displayservers/Wayland/clipboard.c @@ -446,7 +446,7 @@ void waylandCBRequest(LG_ClipboardData type) wl_data_offer_receive(wlCb.offer, wlCb.mimetypes[type], fds[1]); close(fds[1]); - struct ClipboardRead * data = malloc(sizeof(struct ClipboardRead)); + struct ClipboardRead * data = malloc(sizeof(*data)); if (!data) { DEBUG_ERROR("Failed to allocate memory to read clipboard"); @@ -518,7 +518,7 @@ static void dataSourceHandleSend(void * data, struct wl_data_source * source, struct WCBTransfer * transfer = (struct WCBTransfer *) data; if (containsMimetype(transfer->mimetypes, mimetype)) { - struct ClipboardWrite * data = malloc(sizeof(struct ClipboardWrite)); + struct ClipboardWrite * data = malloc(sizeof(*data)); if (!data) { DEBUG_ERROR("Out of memory trying to allocate ClipboardWrite"); @@ -554,7 +554,7 @@ static const struct wl_data_source_listener dataSourceListener = { static void waylandCBReplyFn(void * opaque, LG_ClipboardData type, uint8_t * data, uint32_t size) { - struct WCBTransfer * transfer = malloc(sizeof(struct WCBTransfer)); + struct WCBTransfer * transfer = malloc(sizeof(*transfer)); if (!transfer) { DEBUG_ERROR("Out of memory when allocating WCBTransfer"); diff --git a/client/displayservers/Wayland/poll.c b/client/displayservers/Wayland/poll.c index d610a7e1..4250f701 100644 --- a/client/displayservers/Wayland/poll.c +++ b/client/displayservers/Wayland/poll.c @@ -135,7 +135,7 @@ static void waylandPollRemoveNode(struct WaylandPoll * node) bool waylandPollRegister(int fd, WaylandPollCallback callback, void * opaque, uint32_t events) { - struct WaylandPoll * node = malloc(sizeof(struct WaylandPoll)); + struct WaylandPoll * node = malloc(sizeof(*node)); if (!node) return false; diff --git a/client/displayservers/Wayland/presentation.c b/client/displayservers/Wayland/presentation.c index 216c846b..c96dd4ce 100644 --- a/client/displayservers/Wayland/presentation.c +++ b/client/displayservers/Wayland/presentation.c @@ -107,7 +107,7 @@ void waylandPresentationFrame(void) if (!wlWm.presentation) return; - struct FrameData * data = malloc(sizeof(struct FrameData)); + struct FrameData * data = malloc(sizeof(*data)); if (clock_gettime(wlWm.clkId, &data->sent)) { DEBUG_ERROR("clock_gettime failed: %s\n", strerror(errno)); diff --git a/client/displayservers/Wayland/window.c b/client/displayservers/Wayland/window.c index 136d35c9..a9dc7372 100644 --- a/client/displayservers/Wayland/window.c +++ b/client/displayservers/Wayland/window.c @@ -56,7 +56,7 @@ void waylandWindowUpdateScale(void) static void wlSurfaceEnterHandler(void * data, struct wl_surface * surface, struct wl_output * output) { - struct SurfaceOutput * node = malloc(sizeof(struct SurfaceOutput)); + struct SurfaceOutput * node = malloc(sizeof(*node)); node->output = output; wl_list_insert(&wlWm.surfaceOutputs, &node->link); waylandWindowUpdateScale(); diff --git a/client/displayservers/X11/clipboard.c b/client/displayservers/X11/clipboard.c index 46cd0093..d50ea313 100644 --- a/client/displayservers/X11/clipboard.c +++ b/client/displayservers/X11/clipboard.c @@ -153,7 +153,7 @@ static void x11CBReplyFn(void * opaque, LG_ClipboardData type, static void x11CBSelectionRequest(const XSelectionRequestEvent e) { - XEvent * s = (XEvent *)malloc(sizeof(XEvent)); + XEvent * s = (XEvent *)malloc(sizeof(*s)); s->xselection.type = SelectionNotify; s->xselection.requestor = e.requestor; s->xselection.selection = e.selection; diff --git a/client/renderers/EGL/cursor.c b/client/renderers/EGL/cursor.c index a356766a..b9b830ca 100644 --- a/client/renderers/EGL/cursor.c +++ b/client/renderers/EGL/cursor.c @@ -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, diff --git a/client/renderers/EGL/damage.c b/client/renderers/EGL/damage.c index a5128b94..99d4969d 100644 --- a/client/renderers/EGL/damage.c +++ b/client/renderers/EGL/damage.c @@ -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"); diff --git a/client/renderers/EGL/desktop_rects.c b/client/renderers/EGL/desktop_rects.c index 27ace631..49ce9eaf 100644 --- a/client/renderers/EGL/desktop_rects.c +++ b/client/renderers/EGL/desktop_rects.c @@ -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); diff --git a/client/renderers/EGL/draw.c b/client/renderers/EGL/draw.c index 265eacbf..9f299d84 100644 --- a/client/renderers/EGL/draw.c +++ b/client/renderers/EGL/draw.c @@ -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) diff --git a/client/renderers/EGL/model.c b/client/renderers/EGL/model.c index 225533c9..6e4a1c25 100644 --- a/client/renderers/EGL/model.c +++ b/client/renderers/EGL/model.c @@ -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); diff --git a/client/renderers/EGL/splash.c b/client/renderers/EGL/splash.c index 7428ef2e..0c870584 100644 --- a/client/renderers/EGL/splash.c +++ b/client/renderers/EGL/splash.c @@ -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)) { diff --git a/client/src/app.c b/client/src/app.c index 3f4a29ff..e31d7927 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -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; diff --git a/client/src/ll.c b/client/src/ll.c index 50675407..ff6752e4 100644 --- a/client/src/ll.c +++ b/client/src/ll.c @@ -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; diff --git a/client/src/overlay/graphs.c b/client/src/overlay/graphs.c index bef9bfc1..5fc6e5f3 100644 --- a/client/src/overlay/graphs.c +++ b/client/src/overlay/graphs.c @@ -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;