CVS update: php3/functions
| From: | sas | Date: | Mon, 28 Dec 1998 08:43:30 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3094@lists.php.net to get a copy of this message | ||
Date: Monday December 28, 1998 @ 3:43
Author: sas
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv4627
Modified Files:
reg.c
Log Message:
close mem leaks by reintroducing regfree
rename private functions
Index: php3/functions/reg.c
diff -c php3/functions/reg.c:1.91 php3/functions/reg.c:1.92
*** php3/functions/reg.c:1.91 Mon Dec 28 03:28:40 1998
--- php3/functions/reg.c Mon Dec 28 03:43:29 1998
***************
*** 28,34 ****
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
+----------------------------------------------------------------------+
*/
! /* $Id: reg.c,v 1.91 1998/12/28 08:28:40 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 28,34 ----
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
+----------------------------------------------------------------------+
*/
! /* $Id: reg.c,v 1.92 1998/12/28 08:43:29 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 72,78 ****
static HashTable ht_rc;
! static int php3_regcomp(regex_t *preg, const char *pattern, int cflags)
{
int r = 0;
int patlen = strlen(pattern);
--- 72,78 ----
static HashTable ht_rc;
! static int _php3_regcomp(regex_t *preg, const char *pattern, int cflags)
{
int r = 0;
int patlen = strlen(pattern);
***************
*** 93,100 ****
}
return r;
}
#else
! #define php3_regcomp(a,b,c) regcomp(a,b,c)
#endif
/*
--- 93,104 ----
}
return r;
}
+
+ #define _php3_regfree(a);
+
#else
! #define _php3_regcomp(a,b,c) regcomp(a,b,c)
! #define _php3_regfree(a) regfree(a)
#endif
/*
***************
*** 179,196 ****
/* compile the regular expression from the supplied regex */
if (regex->type == IS_STRING) {
! err = php3_regcomp(&re, regex->value.str.val, REG_EXTENDED | copts);
} else {
/* we convert numbers to integers and treat them as a string */
if (regex->type == IS_DOUBLE)
convert_to_long(regex); /* get rid of decimal places */
convert_to_string(regex);
/* don't bother doing an extended regex with just a number */
! err = php3_regcomp(&re, regex->value.str.val, copts);
}
if (err) {
_php3_reg_eprint(err, &re);
RETURN_FALSE;
}
--- 183,201 ----
/* compile the regular expression from the supplied regex */
if (regex->type == IS_STRING) {
! err = _php3_regcomp(&re, regex->value.str.val, REG_EXTENDED | copts);
} else {
/* we convert numbers to integers and treat them as a string */
if (regex->type == IS_DOUBLE)
convert_to_long(regex); /* get rid of decimal places */
convert_to_string(regex);
/* don't bother doing an extended regex with just a number */
! err = _php3_regcomp(&re, regex->value.str.val, copts);
}
if (err) {
_php3_reg_eprint(err, &re);
+ _php3_regfree(&re);
RETURN_FALSE;
}
***************
*** 243,248 ****
--- 248,254 ----
match_len = 1;
RETVAL_LONG(match_len);
}
+ _php3_regfree(&re);
}
/* {{{ proto int ereg(string pattern, string string [, array registers])
***************
*** 284,290 ****
copts = REG_ICASE;
if (extended)
copts |= REG_EXTENDED;
! err = php3_regcomp(&re, pattern, copts);
if (err) {
_php3_reg_eprint(err, &re);
return ((char *) -1);
--- 290,296 ----
copts = REG_ICASE;
if (extended)
copts |= REG_EXTENDED;
! err = _php3_regcomp(&re, pattern, copts);
if (err) {
_php3_reg_eprint(err, &re);
return ((char *) -1);
***************
*** 296,301 ****
--- 302,308 ----
buf = emalloc(buf_len * sizeof(char));
if (!buf) {
php3_error(E_WARNING, "Unable to allocate memory in _php3_regreplace");
+ _php3_regfree(&re);
return ((char *) -1);
}
***************
*** 307,312 ****
--- 314,320 ----
if (err && err != REG_NOMATCH) {
_php3_reg_eprint(err, &re);
+ _php3_regfree(&re);
return ((char *) -1);
}
if (!err) {
***************
*** 394,399 ****
--- 402,409 ----
}
}
+ _php3_regfree(&re);
+
/* whew. */
return (buf);
}
***************
*** 507,519 ****
strp = str->value.str.val;
endp = str->value.str.val + strlen(str->value.str.val);
! err = php3_regcomp(&re, spliton->value.str.val, REG_EXTENDED);
if (err) {
php3_error(E_WARNING, "unexpected regex error (%d)", err);
RETURN_FALSE;
}
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
--- 517,530 ----
strp = str->value.str.val;
endp = str->value.str.val + strlen(str->value.str.val);
! err = _php3_regcomp(&re, spliton->value.str.val, REG_EXTENDED);
if (err) {
php3_error(E_WARNING, "unexpected regex error (%d)", err);
RETURN_FALSE;
}
if (array_init(return_value) == FAILURE) {
+ _php3_regfree(&re);
RETURN_FALSE;
}
***************
*** 527,532 ****
--- 538,544 ----
} else if (subs[0].rm_so==0 && subs[0].rm_eo==0) {
/* No more matches */
php3_error(E_WARNING, "bad regular expression for split()");
+ _php3_regfree(&re);
_php3_hash_destroy(return_value->value.ht);
efree(return_value->value.ht);
RETURN_FALSE;
***************
*** 561,566 ****
--- 573,579 ----
add_next_index_stringl(return_value, strp, size, 1);
+ _php3_regfree(&re);
return;
}
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net