Blender  V3.3
WindowData.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
4 #include <stdlib.h>
5 
6 #include "MEM_guardedalloc.h"
7 
8 #include "GHOST_C-api.h"
9 
10 #include "WindowData.h"
11 
12 struct _WindowData {
13  void *data;
15 };
16 
18 {
19  WindowData *wb = MEM_mallocN(sizeof(*wb), "windowdata_new");
20  wb->data = data;
21  wb->handler = handler;
22 
23  return wb;
24 }
25 
26 void windowdata_handle(WindowData *wb, GHOST_EventHandle evt)
27 {
28  wb->handler(wb->data, evt);
29 }
30 
32 {
33  MEM_freeN(wb);
34 }
GHOST C-API function and type declarations.
Read Guarded memory(de)allocation.
void windowdata_free(WindowData *wb)
Definition: WindowData.c:31
WindowData * windowdata_new(void *data, WindowDataHandler handler)
Definition: WindowData.c:17
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt)
Definition: WindowData.c:26
void(* WindowDataHandler)(void *priv, GHOST_EventHandle evt)
Definition: WindowData.h:4
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
WindowDataHandler handler
Definition: WindowData.c:14
void * data
Definition: WindowData.c:13