- Use alloca() when possible.

This commit is contained in:
Andi Gutmans 2001-12-01 08:33:48 +00:00
parent c45f699830
commit bb9a36cad1
2 changed files with 12 additions and 5 deletions

View File

@ -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 **) &register_class);
free(lowercase_name);
free_alloca(lowercase_name);
return register_class;
}

View File

@ -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;
}