* store references in that cache, cleanup
This commit is contained in:
@ -27,7 +27,7 @@ struct _MuMsgCache {
|
|||||||
/* all string properties */
|
/* all string properties */
|
||||||
char *_str[MU_MSG_STRING_FIELD_ID_NUM];
|
char *_str[MU_MSG_STRING_FIELD_ID_NUM];
|
||||||
|
|
||||||
GSList *_refs;
|
GSList *_refs, *_tags;
|
||||||
|
|
||||||
time_t _timestamp, _date;
|
time_t _timestamp, _date;
|
||||||
size_t _size;
|
size_t _size;
|
||||||
@ -50,26 +50,36 @@ struct _MuMsgCache {
|
|||||||
#define reset_allocated(C,MFID) ((C)->_allocated &= ~(1 << (MFID)))
|
#define reset_allocated(C,MFID) ((C)->_allocated &= ~(1 << (MFID)))
|
||||||
#define reset_cached(C,MFID) ((C)->_cached &= ~(1 << (MFID)))
|
#define reset_cached(C,MFID) ((C)->_cached &= ~(1 << (MFID)))
|
||||||
|
|
||||||
MuMsgCache*
|
|
||||||
mu_msg_cache_new (void)
|
static void
|
||||||
|
cache_clear (MuMsgCache *self)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
MuMsgCache *self;
|
|
||||||
|
|
||||||
self = g_slice_new (MuMsgCache);
|
|
||||||
|
|
||||||
for (i = 0; i != MU_MSG_STRING_FIELD_ID_NUM; ++i)
|
for (i = 0; i != MU_MSG_STRING_FIELD_ID_NUM; ++i)
|
||||||
self->_str[i] = NULL;
|
self->_str[i] = NULL;
|
||||||
|
|
||||||
self->_timestamp = (time_t)-1;
|
self->_timestamp = (time_t)-1;
|
||||||
self->_size = (size_t)-1;
|
self->_size = (size_t)-1;
|
||||||
self->_flags = MU_MSG_FLAG_NONE;
|
self->_flags = MU_MSG_FLAG_NONE;
|
||||||
self->_prio = MU_MSG_PRIO_NONE;
|
self->_prio = MU_MSG_PRIO_NONE;
|
||||||
self->_date = (time_t)-1;
|
self->_date = (time_t)-1;
|
||||||
|
|
||||||
|
self->_refs = self->_tags = NULL;
|
||||||
|
|
||||||
self->_cached = 0;
|
self->_cached = 0;
|
||||||
self->_allocated = 0;
|
self->_allocated = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MuMsgCache*
|
||||||
|
mu_msg_cache_new (void)
|
||||||
|
{
|
||||||
|
MuMsgCache *self;
|
||||||
|
|
||||||
|
self = g_slice_new0 (MuMsgCache);
|
||||||
|
cache_clear (self);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +88,7 @@ void
|
|||||||
mu_msg_cache_destroy (MuMsgCache *self)
|
mu_msg_cache_destroy (MuMsgCache *self)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!self)
|
if (!self)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -88,6 +98,9 @@ mu_msg_cache_destroy (MuMsgCache *self)
|
|||||||
if (is_allocated(self, i))
|
if (is_allocated(self, i))
|
||||||
g_free (self->_str[i]);
|
g_free (self->_str[i]);
|
||||||
|
|
||||||
|
mu_str_free_list (self->_tags);
|
||||||
|
mu_str_free_list (self->_refs);
|
||||||
|
|
||||||
g_slice_free (MuMsgCache, self);
|
g_slice_free (MuMsgCache, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +147,16 @@ mu_msg_cache_set_str_list (MuMsgCache *self, MuMsgFieldId mfid,
|
|||||||
|
|
||||||
switch (mfid) {
|
switch (mfid) {
|
||||||
case MU_MSG_FIELD_ID_REFS:
|
case MU_MSG_FIELD_ID_REFS:
|
||||||
case MU_MSG_FIELD_ID_TAGS:
|
|
||||||
if (is_allocated(self, mfid))
|
if (is_allocated(self, mfid))
|
||||||
mu_str_free_list (self->_refs);
|
mu_str_free_list (self->_refs);
|
||||||
self->_refs = lst;
|
self->_refs = lst;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MU_MSG_FIELD_ID_TAGS:
|
||||||
|
if (is_allocated(self, mfid))
|
||||||
|
mu_str_free_list (self->_tags);
|
||||||
|
self->_tags = lst;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_return_val_if_reached(NULL);
|
g_return_val_if_reached(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user