mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] use variable-relative sizeof where possible
This commit is contained in:
parent
1c5620ba25
commit
14ad83c6b8
@ -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");
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user