xutil: stop leaking atom when called with no cache

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-27 11:13:33 +02:00
parent 0fddca87c3
commit ba13fba67c
1 changed files with 8 additions and 5 deletions

View File

@ -210,6 +210,7 @@ xutil_intern_atom_reply(xcb_connection_t *c,
{ {
xcb_intern_atom_reply_t *atom_rep; xcb_intern_atom_reply_t *atom_rep;
xutil_atom_cache_t *atom_cache, *atom_next; xutil_atom_cache_t *atom_cache, *atom_next;
xcb_atom_t atom;
/* If the atom is present in the cache, just returns the /* If the atom is present in the cache, just returns the
* atom... */ * atom... */
@ -223,13 +224,15 @@ xutil_intern_atom_reply(xcb_connection_t *c,
return 0; return 0;
} }
atom = atom_rep->atom;
if(atoms)
{
/* Create a new atom cache entry */ /* Create a new atom cache entry */
atom_cache = p_new(xutil_atom_cache_t, 1); atom_cache = p_new(xutil_atom_cache_t, 1);
atom_cache->atom = atom_rep->atom; atom_cache->atom = atom_rep->atom;
atom_cache->name = atom_req.name; atom_cache->name = atom_req.name;
if(atoms)
{
/* Add the entry in the list at the beginning of the cache list */ /* Add the entry in the list at the beginning of the cache list */
if(*atoms == NULL || a_strcmp(atom_req.name, (*atoms)->name) < 0) if(*atoms == NULL || a_strcmp(atom_req.name, (*atoms)->name) < 0)
atom_cache_list_push(atoms, atom_cache); atom_cache_list_push(atoms, atom_cache);
@ -247,7 +250,7 @@ xutil_intern_atom_reply(xcb_connection_t *c,
p_delete(&atom_rep); p_delete(&atom_rep);
return atom_cache->atom; return atom;
} }
/* Delete a atom cache entry. /* Delete a atom cache entry.