Get lost in Phalcon internal API

41 views
Skip to first unread message

hdo...@gmail.com

unread,
Oct 23, 2012, 5:04:51 AM10/23/12
to phalcon-...@googlegroups.com
Hello,

I'm trying to solve my crash and memory leak problems with reading API source code and trying macros/functions. Trying to understand Phalcon API with reading it's source and then understanding Zend API is time consuming (since zend api has no documentation, I try to read zend engine source code)

It would be nice to have some small how-to/where-to-use documentation about some macros/functions of Phalcon.

Ie, in which conditions to use:

PHALCON_INIT_VAR and PHALCON_INI_NVAR (I understand NVAR clears variable reference if exists and nulls then allocates the memory).
PHALCON_SEPARATE_PARAM
PHALCON_OBSERVE_VAR
PHALCON_CPY_WRT/CPY_WRT_CTOR
RETURN_CTOR and RETURN_CCTOR/CCTORW (cctor and cctorw is same?)
PH_CTOR, PH_COPY and PH_SEPARATE (PH_SEPARATE creates new variable with reference of given var and deletes original one? - PH_COPY just uses reference of given var?)

in which condition to define variables with passing default value NULL (I have solved some of my crash problems with defining default value as NULL)

when to use
zend_is_true and if (variable) or if (!variable) PHALCON_IS_TRUE/FALSE, etc.

I don't know why but I feel that my code is lots of memory leaks...

A small introduction for internal API would be very handful.

Nikolaos Dimopoulos

unread,
Oct 23, 2012, 12:20:28 PM10/23/12
to hdo...@gmail.com, phalcon-...@googlegroups.com
Hey Hidayet,

Have you looked at this?


The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.


--
 
 

hdo...@gmail.com

unread,
Oct 23, 2012, 12:52:36 PM10/23/12
to phalcon-...@googlegroups.com, hdo...@gmail.com
Yes but I couldn't find some of the internal macro/function documentation. Like PHALCON_INIT_NVAR/RETURN_CCTOR, PH_COPY, PH_SEPARATE, etc.

Andres-Gutierrez

unread,
Oct 23, 2012, 1:02:59 PM10/23/12
to hdo...@gmail.com, phalcon-...@googlegroups.com
PHALCON_INIT_VAR is used if the variable it's initialized for the first time, it doesn't requires that the variable will be initialized with null in its declaration.

PHALCON_INIT_NVAR is used if the variable it's initialized for second, third, etc time, also if the variable is used inside a cycle.

variables that are type IS_ARRAY, IS_STRING, IS_OBJECT additional to its value have a "body", those variables should be returned using RETURN_CTOR, (return+ctor)

if the variable is IS_NULL, IS_BOOL, IS_LONG, IS_DOUBLE it can be returned with RETURN_NCTOR (no-ctor)

if you aren't sure about the type of a variable you wan use RETURN_CCTOR (return-check-ctor)

Also, the previous macros implicitly calls PHALCON_MM_RESTORE, cleaning the memory used in the current memory frame.

Some methods doesn't create a memory frame, so isn't necessary clean memory, those macros have an extra W (without clean the memory frame)

RETURN_CCTORW
RETURN_NCTORW

--
 
 

Reply all
Reply to author
Forward
0 new messages