[PD-dev] string external & usage count

Matju matju at sympatico.ca
Wed Oct 13 22:00:33 CEST 2004


On Wed, 13 Oct 2004, Tim Blechmann wrote:

> > i don't want to use pointers because if i send an invalid pointer to
> > one of my string objects it will most likely crash pd.
> > therefore i use handles. the worst thing that can happen is that a
> > wrong handle refers to the wrong string. i made tests with wrong
> > handles and it is quite fail safe.
> you could store the pointers in a list and test, if it's valid ... the
> problem with ints that are represented by floats ... you will have a
> point when (x+1 == x) returns true ... which might be a wonderful source
> for errors ...

That number is 1<<24, that is, 16777216, for the float32 type. If you want
to pass anything else with more bits, the trick is that, if you have a int
x and a float y, instead of doing x=y you'd do *(int *)x = y;

but don't expect things pointers converted to text and back to work, even
if within the 1<<24 range, because of binary-to-decimal conversion, which
by itself isn't so bad, but Pd chops off extra digits.

____________________________________________________________________
Matsjö Buschahr @ Ruby Konferenz, Muenchen
http://artengine.ca/matju                                           






More information about the Pd-dev mailing list