Boost logo

Boost :

From: Norman Shelley (rrdn60) (rrdn60_at_[hidden])
Date: 2001-04-10 12:45:05


I am building a boost python extension (dynamically loaded shared library)
using boost 1.21.1, python2.1b2, gcc 2.95.3 on HPUX. It is working very
nicely, thanks to all those who provided it.

I have a function that gets called from within my python environment (see
below).

Do I need to explicitly destroy the alist instance and if alist.size() is >
0 the atuple, err, ... instances?
If so, what is the correct way to do it?

(Any other style or substance suggestions are welcome also.)

Norman Shelley

....
 void deletePlots(python::tuple names)
 {
  PlotHandle hndl;
  const char *name;
  python::list alist = python::list();

  for (int i = 0; i < names.size(); i++) {
   name = BOOST_PYTHON_CONVERSION::from_python(names[i].get(),
python::type<const
char*>());
   hndl = getPlotByName((char *) name);
   if (deletePlot(hndl) == False) {
    alist.append(names[i]);
   }
  }

  if (alist.size() > 0) {
    python::tuple atuple = python::tuple(1);
    atuple.set_item(0, alist);
    python::string err = python::string("deletePlot(s) %s failed") %
atuple;

    PyErr_SetString(MicaError, err.c_str());
    throw python::error_already_set();
  }
 }

....

  this_module.def(deletePlotsAll, "deletePlots");


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk