[GiNaC-list] hash tables and sets
Richard B. Kreckel
kreckel at ginac.de
Wed Oct 11 21:27:10 CEST 2006
Dear Marko,
Marko Riedel wrote:
>Someone hands me a chunk of memory through a void pointer, like so:
>
> (void *)ptr.
>
>I want the memory pointed to by "ptr" to hold a newly initialized set
>of GiNaC expressions. How do I do this? How do I find out the number
>of bytes I will need? At some point in the future, someone will hand
>me that same pointer and I will want to free the set of expressions
>that it holds. Again, how do I do this?
>
Same as before. Don't let yourself be fooled by a funny long type name
instead of a crisp "mystruct".
I suppose that should work (I haven't actually tested it):
typedef std::set<GiNaC::ex, GiNaC::ex_is_less> myset; // shorthand
myset* inst;
inst = (myset*)malloc(sizeof(myset)); // or get inst from elsewhere
new(inst) myset;
// do stuff to *inst here...
inst->~myset();
delete inst;
Again: this is dirty stuff. But you wanted to do some interfacing. So be
it...
Regards
-richy.
--
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
More information about the GiNaC-list
mailing list