mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
- Use alloca() when possible.
This commit is contained in:
parent
c45f699830
commit
bb9a36cad1
@ -1206,7 +1206,10 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
|
||||
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC)
|
||||
{
|
||||
zend_class_entry *register_class;
|
||||
char *lowercase_name = zend_strndup(class_entry->name, class_entry->name_length);
|
||||
char *lowercase_name;
|
||||
|
||||
lowercase_name = do_alloca(class_entry->name_length+1);
|
||||
memcpy(lowercase_name, class_entry->name, class_entry->name_length+1);
|
||||
|
||||
zend_str_tolower(lowercase_name, class_entry->name_length);
|
||||
|
||||
@ -1226,7 +1229,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_
|
||||
}
|
||||
|
||||
zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, class_entry, sizeof(zend_class_entry), (void **) ®ister_class);
|
||||
free(lowercase_name);
|
||||
free_alloca(lowercase_name);
|
||||
return register_class;
|
||||
}
|
||||
|
||||
|
@ -220,9 +220,12 @@ ZEND_API void zend_register_string_constant(char *name, uint name_len, char *str
|
||||
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC)
|
||||
{
|
||||
zend_constant *c;
|
||||
char *lookup_name = estrndup(name, name_len);
|
||||
char *lookup_name;
|
||||
int retval;
|
||||
|
||||
lookup_name = do_alloca(name_len+1);
|
||||
memcpy(lookup_name, name, name_len+1);
|
||||
|
||||
zend_str_tolower(lookup_name, name_len);
|
||||
|
||||
if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
|
||||
@ -236,8 +239,9 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
|
||||
} else {
|
||||
retval=0;
|
||||
}
|
||||
|
||||
efree(lookup_name);
|
||||
|
||||
free_alloca(lookup_name);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user