cvs: pecl /translit translit.c

From: Date: Sun, 24 Oct 2004 20:51:55 +0000
Subject: cvs: pecl /translit translit.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-1977@lists.php.net to get a copy of this message
derick Sun Oct 24 16:51:55 2004 EDT Modified files: /pecl/translit translit.c Log: - Fixed memleak and added prototype http://cvs.php.net/diff.php/pecl/translit/translit.c?r1=1.2&r2=1.3&ty=u Index: pecl/translit/translit.c diff -u pecl/translit/translit.c:1.2 pecl/translit/translit.c:1.3 --- pecl/translit/translit.c:1.2 Sun Oct 24 11:13:25 2004 +++ pecl/translit/translit.c Sun Oct 24 16:51:54 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: translit.c,v 1.2 2004/10/24 15:13:25 derick Exp $ */ +/* $Id: translit.c,v 1.3 2004/10/24 20:51:54 derick Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -97,6 +97,8 @@ return NULL; } +/* {{{ proto string transliterate(string string, array filter_list) + Executes the specified filters on the input string */ PHP_FUNCTION(transliterate) { zval *filter_list, **entry; @@ -104,12 +106,12 @@ HashPosition pos; translit_func_t filter; long str_len; + int free_it = 0; unsigned char *string, *outs; unsigned short *in, *out; unsigned int inl, outl; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa", &string, &str_len, &filter_list) == FAILURE) { return; } @@ -122,14 +124,21 @@ if (Z_TYPE_PP(entry) == IS_STRING) { if (filter = translit_find_filter(Z_STRVAL_PP(entry))) { filter(in, inl, &out, &outl); + if (free_it) { + free(in); + } else { + free_it = 1; + } in = out; inl = outl; } } zend_hash_move_forward_ex(target_hash, &pos); } - RETURN_STRINGL((unsigned char *)out, outl*2, 1); + RETVAL_STRINGL((unsigned char *)out, outl*2, 1); + free(out); } +/* }}} */ /* * Local variables: * tab-width: 4

« previous php.pecl.cvs (#1977) next »