pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] Patch for FS#56 (second try)


From: jemarch
Subject: Re: [pdf-devel] Patch for FS#56 (second try)
Date: Wed, 23 Jul 2008 01:54:45 +0200
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

    > Would be good to explain there what the function does if the parameter
    > is NULL.

   Sure.

Ok. Please add the complete description to your patch.

    >    +  if (pdf_hash_add (props_hash, "isHidden", (void *) is_hidden,NULL) 
!=
    >    +      PDF_OK)
    >    +    {
    >    +      return PDF_ERROR;
    >    +    }
    > 
    > Will the memory used by 'is_hidden' be released when the hash is
    > destroyed being the last parameter NULL? As far as I understand in
    > this case the dispose function defined for the hash will be applied.

   Right, we have two choices,

   1. we pass each function call the element dispose function.

I would prefer this one.

   2. we give it at creation time, i.e. pdf_hash_create(). But now
   that I see pdf_fsys_item_props_to_hash() doesn't create the hash
   table, which should if we want to do this.

I would remove the possibility to use a table-wide memory disposal
function. Hashes tend to hold heterogeous values. That is certainly
our case where we will use hashes to implement the PDF dictionaries.

    >  newelt->key = key;
    >  ...
    >  gl_sortedlist_add ((gl_list_t)table.keys, key_compare, key);
    > 
    > Is 'gl_sortedlist_add' making a copy of 'key'?

   No, it is not. Also, remember that if the key is allocated from the
   heap you could give pdf_hash_create() the key dispose function if
   you need to.

The keys are always raw strings, isnt it? If it is the case I would
say to let the hash implementation to make a copy of it and manage its
memory. 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]