FAQ
I have a zval *obj holding an object of class B, which I then add to an
array member of another object of class A. Then I create a new instance
*obj2 of class B, to which I want to add a reference to *obj. How would
I best go about it?

So A works as a "pool" of B's, and B's may reference to each other.

Please tell me key functions and macros to use to accomplish
specifically this thing, as the API is quite new to me.

I have thought about setting Z_SET_ISREF_P() manually, but what else
would I need? From my understanding, I'd still need a new zval* for
that. Any other better ways?

Regards,
Flavius

Search Discussions

  • Etienne Kneuss at Aug 2, 2011 at 9:03 pm
    Hello,
    On Tue, Aug 2, 2011 at 22:05, Flavius Aspra wrote:
    I have a zval *obj holding an object of class B, which I then add to an
    array member of another object of class A. Then I create a new instance
    *obj2 of class B, to which I want to add a reference to *obj. How would I
    best go about it?

    So A works as a "pool" of B's, and B's may reference to each other.

    Please tell me key functions and macros to use to accomplish specifically
    this thing, as the API is quite new to me.

    I have thought about setting Z_SET_ISREF_P() manually, but what else would I
    need? From my understanding, I'd still need a new zval* for that. Any other
    better ways?
    You generally don't want to use references.

    Rather, you can keep the same zval* pointer as long as you
    increment/decrement its refcount (Z_ADDREF_P/zval_ptr_dtor) so that it
    correctly keeps track of how many pointers are pointing to it.

    Unless I misunderstood what you're trying to do, it's that easy.

    Best,
    Regards,
    Flavius

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php


    --
    Etienne Kneuss
    http://www.colder.ch

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedAug 2, '11 at 8:12p
activeAug 2, '11 at 9:03p
posts2
users2
websitephp.net

2 users in discussion

Flavius Aspra: 1 post Etienne Kneuss: 1 post

People

Translate

site design / logo © 2022 Grokbase