Blender  V2.93
wm_utils.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
23 #include "WM_api.h"
24 #include "WM_types.h"
25 
26 #include "MEM_guardedalloc.h"
27 
28 /* -------------------------------------------------------------------- */
33 {
34  if (callback->free_user_data) {
35  callback->free_user_data(callback->user_data);
36  }
38 }
39 
40 static void do_nothing(struct bContext *UNUSED(C), void *UNUSED(user_data))
41 {
42 }
43 
45 {
46  wmGenericCallback *new_callback = MEM_dupallocN(callback);
47  callback->exec = do_nothing;
48  callback->free_user_data = NULL;
49  callback->user_data = NULL;
50  return new_callback;
51 }
52 
55 /* -------------------------------------------------------------------- */
60 {
61  if (wm_userdata->data && wm_userdata->use_free) {
62  if (wm_userdata->free_fn) {
63  wm_userdata->free_fn(wm_userdata->data);
64  }
65  else {
66  MEM_freeN(wm_userdata->data);
67  }
68  }
69 }
70 
#define UNUSED(x)
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
void * user_data
DEGForeachIDComponentCallback callback
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void(* free_fn)(void *data)
Definition: WM_types.h:138
wmGenericCallback * WM_generic_callback_steal(wmGenericCallback *callback)
Definition: wm_utils.c:44
void WM_generic_callback_free(wmGenericCallback *callback)
Definition: wm_utils.c:32
void WM_generic_user_data_free(wmGenericUserData *wm_userdata)
Definition: wm_utils.c:59
static void do_nothing(struct bContext *UNUSED(C), void *UNUSED(user_data))
Definition: wm_utils.c:40