mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add CACHE_REPLACE(dst, src) macro for common case in string setters.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12319 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
eaa9d47eab
commit
32a5612d4c
@ -305,8 +305,22 @@ void gnc_string_cache_remove(gconstpointer key);
|
||||
*/
|
||||
gpointer gnc_string_cache_insert(gconstpointer key);
|
||||
|
||||
#define CACHE_INSERT(str) gnc_string_cache_insert((gconstpointer)(str));
|
||||
#define CACHE_REMOVE(str) gnc_string_cache_remove((str));
|
||||
#define CACHE_INSERT(str) gnc_string_cache_insert((gconstpointer)(str))
|
||||
#define CACHE_REMOVE(str) gnc_string_cache_remove((str))
|
||||
|
||||
/* Replace cached string currently in 'dst' with string in 'src'.
|
||||
* Typical usage:
|
||||
* void foo_set_name(Foo *f, const char *str) {
|
||||
* CACHE_REPLACE(f->name, str);
|
||||
* }
|
||||
* It avoids unnecessary ejection by doing INSERT before REMOVE.
|
||||
*/
|
||||
#define CACHE_REPLACE(dst, src) do { \
|
||||
gpointer tmp = CACHE_INSERT((src)); \
|
||||
CACHE_REMOVE((dst)); \
|
||||
(dst) = tmp; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#endif /* QOF_UTIL_H */
|
||||
/** @} */
|
||||
|
Loading…
Reference in New Issue
Block a user