GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qof-string-cache.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qof-string-cache.h -- QOF string cache functions *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA [email protected] *
20 \********************************************************************/
21 
33 #ifndef QOF_STRING_UTIL_H
34 #define QOF_STRING_UTIL_H
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 #define QOF_MOD_UTIL "qof.utilities"
42 
74 void qof_string_cache_init(void);
75 
77 void qof_string_cache_destroy(void);
78 
82 void qof_string_cache_remove(gconstpointer key);
83 
87 gpointer qof_string_cache_insert(gconstpointer key);
88 
89 #define CACHE_INSERT(str) qof_string_cache_insert((gconstpointer)(str))
90 #define CACHE_REMOVE(str) qof_string_cache_remove((str))
91 
92 /* Replace cached string currently in 'dst' with string in 'src'.
93  * Typical usage:
94  * void foo_set_name(Foo *f, const char *str) {
95  * CACHE_REPLACE(f->name, str);
96  * }
97  * It avoids unnecessary ejection by doing INSERT before REMOVE.
98 */
99 #define CACHE_REPLACE(dst, src) do { \
100  gpointer tmp = CACHE_INSERT((src)); \
101  CACHE_REMOVE((dst)); \
102  (dst) = tmp; \
103  } while (0)
104 
105 #define QOF_CACHE_NEW(void) qof_string_cache_insert("")
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* QOF_STRING_CACHE_H */
112 
void qof_string_cache_destroy(void)
void qof_string_cache_remove(gconstpointer key)
gpointer qof_string_cache_insert(gconstpointer key)
void qof_string_cache_init(void)