From: Sascha Schumann Date: Sun, 22 Oct 2000 14:42:55 +0000 (+0000) Subject: We don't need to store NUL of the key which simplifies the lookup X-Git-Tag: php-4.0.4RC3~561 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61cf1f34a5cc871fc6c8cfb035ac604bf27a7953;p=php We don't need to store NUL of the key which simplifies the lookup significantly. --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 609107e531..62a3bb5cd3 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -91,7 +91,7 @@ PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path PLS_FETCH(); if(PG(allow_url_fopen)) { - return zend_hash_add(&fopen_url_wrappers_hash, protocol, strlen(protocol)+1, &wrapper, sizeof(wrapper), NULL); + return zend_hash_add(&fopen_url_wrappers_hash, protocol, strlen(protocol), &wrapper, sizeof(wrapper), NULL); } else { return FAILURE; } @@ -102,7 +102,7 @@ PHPAPI int php_unregister_url_wrapper(char *protocol) PLS_FETCH(); if(PG(allow_url_fopen)) { - return zend_hash_del(&fopen_url_wrappers_hash, protocol, strlen(protocol)+1); + return zend_hash_del(&fopen_url_wrappers_hash, protocol, strlen(protocol)); } else { return SUCCESS; } @@ -439,16 +439,10 @@ static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, in if(protocol) { php_fopen_url_wrapper_t *wrapper=NULL; - char *protocopy = emalloc(n+1); - - if(protocopy) { - strncpy(protocopy,protocol,n); - protocopy[n]='\0'; - if(FAILURE==zend_hash_find(&fopen_url_wrappers_hash, protocopy, n+1,(void **)&wrapper)) { - wrapper=NULL; - protocol=NULL; - } - efree(protocopy); + + if(FAILURE==zend_hash_find(&fopen_url_wrappers_hash, protocol, n, (void **)&wrapper)) { + wrapper=NULL; + protocol=NULL; } if(wrapper) return (*wrapper)(path, mode, options, issock, socketd, opened_path);