[cairo] Hash rewrite #3: cairo_scaled_font_map

Keith Packard keithp at keithp.com
Thu Aug 11 18:29:34 PDT 2005

On Thu, 2005-08-11 at 17:30 -0700, Carl Worth wrote:
       cairo_scaled_font_map = malloc (sizeof (cairo_scaled_font_map_t));
       if (cairo_scaled_font_map == NULL)
            goto FAIL;

       cairo_scaled_font_map->hash_table =
           _cairo_hash_table_create (_cairo_scaled_font_keys_equal);

       if (cairo_scaled_font_map->hash_table == NULL)
           goto FAIL;

       cairo_scaled_font_map->num_holdovers = 0;

Looks like this doesn't distinguish between a failure to create the font
map and a failure to create the hash table.

    hash = _hash_bytes_fnv ((unsigned char *)(&scaled_font->font_matrix.xx),
                            sizeof(double) * 4,

I assume you're trying to avoid incorporating the translation elements
into the hash; a comment might make that more clear
here (and the one with the ctm as well). I don't think there's a serious
concern that there would be additional padding between double members of
a structure, so the
implementation should be OK.

Should we just set the translation elements to zero and hash the whole
structure instead?

Similarly, should we just memcmp the whole key? I don't see any pointers
in it. Or are you concerned about padding in the options structure?

+    /* If the original reference count is 0, then this font must have
+     * been found in font_map->holdovers, (which means this caching is
+     * actually working). So now we remove it from the holdovers
+     * array. */

Could the removal of this element from the holdover array occur a bit
closer to the code which locates it there? This kind of 'reference == 0'
magic seems fragile to me.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050811/62f3cd27/attachment.pgp

More information about the cairo mailing list