|
|
Choosing A Webhost: |
cvs: ZendEngine2 / zend_constants.c: msg#00042php.cvs.zend
andrei Wed May 26 17:01:37 2004 EDT Modified files: /ZendEngine2 zend_constants.c Log: Avoid unnecessary and silly copying of constant name when registering. http://cvs.php.net/diff.php/ZendEngine2/zend_constants.c?r1=1.66&r2=1.67&ty=u Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.66 ZendEngine2/zend_constants.c:1.67 --- ZendEngine2/zend_constants.c:1.66 Tue Mar 9 10:37:18 2004 +++ ZendEngine2/zend_constants.c Wed May 26 17:01:37 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.66 2004/03/09 15:37:18 andi Exp $ */ +/* $Id: zend_constants.c,v 1.67 2004/05/26 21:01:37 andrei Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -302,7 +302,8 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) { - char *lowercase_name; + char *lowercase_name = NULL; + char *name; int ret = SUCCESS; #if 0 @@ -313,21 +314,22 @@ /* keep in mind that c->name_len already contains the '\0' */ lowercase_name = do_alloca(c->name_len); zend_str_tolower_copy(lowercase_name, c->name, c->name_len - 1); + name = lowercase_name; } else { - lowercase_name = do_alloca(c->name_len + 1); - memcpy(lowercase_name, c->name, c->name_len); - lowercase_name[c->name_len] = '\0'; + name = c->name; } - if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { + if (zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { free(c->name); if (!(c->flags & CONST_PERSISTENT)) { zval_dtor(&c->value); } - zend_error(E_NOTICE,"Constant %s already defined", lowercase_name); + zend_error(E_NOTICE,"Constant %s already defined", name); ret = FAILURE; } - free_alloca(lowercase_name); + if (lowercase_name) { + free_alloca(lowercase_name); + } return ret; } -- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cvs: ZendEngine2 / zend_alloc.c, Andi Gutmans |
|---|---|
| Next by Date: | cvs: Zend(PHP_4_3) / zend_constants.c, Andrei Zmievski |
| Previous by Thread: | cvs: Zend(PHP_4_3) / zend_constants.c, Andrei Zmievski |
| Next by Thread: | cvs: ZendEngine2 / zend_object_handlers.c, Wez Furlong |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |