[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Question about Python bindings

From: John Peacock <john.peacock_at_havurah-software.org>
Date: Wed, 21 May 2008 21:41:21 -0400

I'm trying to translate the Python SWIG bindings to Perl and I came across this
code:

...
   hash = apr_hash_make(pool);
   keys = PyDict_Keys(dict);
   num_keys = PyList_Size(keys);
   for (i = 0; i < num_keys; i++)
     {
       PyObject *key = PyList_GetItem(keys, i);
       PyObject *value = PyDict_GetItem(dict, key);
       const char *pathname = make_string_from_ob(key, pool);
       apr_array_header_t *ranges = svn_swig_py_rangelist_to_array(value, pool);

       if (! (pathname && ranges))
         {
           PyErr_SetString(PyExc_TypeError,
                           "dictionary keys aren't strings or values aren't
svn_merge_range_t *'s");
           Py_DECREF(keys);
           return NULL;
         }
...

If the error path is followed, isn't that hash leaked, or does the pool
automatically get cleaned up somewhere else? I'm trying desperately not to
engage in cargo-cult programming.

TIA

John

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-05-22 03:41:05 CEST

This is an archived mail posted to the Subversion Dev mailing list.