Re: new pecl extension
| From: | Andres Felipe Gutierrez | Date: | Wed, 22 Feb 2012 16:16:10 +0000 |
| Subject: | Re: new pecl extension | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-9180@lists.php.net to get a copy of this message | ||
Of course, I initially use macros to reduce these patterns, but debugging
was very dificult so I expanded them.
Some code are inside cycle blocks so I need to check reference counting to
free them or Zend Engine will report memory leaks.
2012/2/22 Gustavo Lopes <glopes@nebm.ist.utl.pt>
> On Wed, 22 Feb 2012 15:46:39 +0100, Andres Felipe Gutierrez <
> gutierrezandresfelipe@gmail.**com <gutierrezandresfelipe@gmail.com>>
> wrote:
>
> My name is Andres Gutierrez, I'm developing a C extension which goal is
>> to provide a small full stack framework for PHP written in C language.
>>
>> Because frameworks are very popular for many developments out there, I'm
>> trying with extension help to reduce the overhead of load many files and
>> interpret hundreds of lines at each request.
>>
>> The framework provide OO classes for the next components:
>>
>> * Rewrite router
>> * Controller Dispatcher
>> * Views and Layouts
>> * Templating helpers
>> * ORM
>> * Session handling
>> * Request (encapsulates HTTP environment)
>>
>> I have a github repository:
>>
>>
>> https://github.com/phalcon/**cphalcon/tree/master/dev<https://github.com/phalcon/cphalcon/tree/master/dev>
>>
>> May this project become a pecl extension?
>>
>
> The C code is very difficult to read and seems almost generated. For
> instance, see the variable names (and quantity) in
>
> https://github.com/phalcon/**cphalcon/blob/master/dev/**dispatcher.c#L354<https://github.com/phalcon/cphalcon/blob/master/dev/dispatcher.c#L354>
>
> And for some reason, patterns like the one below are all over the code.
> From skimming the code these and similar are most of the time unnecessary.
> Some if branches are clearly never reached (v4 can't have a non-NULL value
> here https://github.com/phalcon/**cphalcon/blob/master/dev/**
>
> dispatcher.c#L390<https://github.com/phalcon/cphalcon/blob/master/dev/dispatcher.c#L390>)
> or are simply very explicit ways to do unnecessary zval copies (see e.g.
>
> https://github.com/phalcon/**cphalcon/blob/master/dev/**dispatcher.c#L1664<https://github.com/phalcon/cphalcon/blob/master/dev/dispatcher.c#L1664>)
>
> if (!r4) {
> PHALCON_ALLOC_ZVAL(r4);
> } else {
> if (Z_REFCOUNT_P(r4) > 1) {
> {
> zval *orig_ptr = r4;
> if (Z_REFCOUNT_P(orig_ptr) > 1) {
> Z_DELREF_P(orig_ptr);
> ALLOC_ZVAL(r4);
> *r4 = *orig_ptr;
> zval_copy_ctor(r4);
> Z_SET_REFCOUNT_P(r4, 1);
> Z_UNSET_ISREF_P(r4);
> }
> }
> } else {
> FREE_ZVAL(r4);
> PHALCON_ALLOC_ZVAL(r4);
> }
> }
>
>
>
> --
> Gustavo Lopes
>