mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Remove redundant NULL checks in mbstring
Whoever originally wrote mbstring seems to have a deathly fear of NULL pointers lurking behind every corner. A common pattern is that one function will check if a pointer is NULL, then pass it to another function, which will again check if it is NULL, then pass to yet another function, which will yet again check if it is NULL... it's NULL checks all the way down. Remove all the NULL checks in places where pointers could not possibly be NULL.
This commit is contained in:
parent
626f0fec54
commit
a312620607
3 changed files with 34 additions and 99 deletions
|
@ -363,7 +363,7 @@ MBSTRING_API char *php_unicode_convert_case(
|
|||
{
|
||||
struct convert_case_data data;
|
||||
mbfl_convert_filter *from_wchar, *to_wchar;
|
||||
mbfl_string result, *result_ptr;
|
||||
mbfl_string result;
|
||||
|
||||
mbfl_memory_device device;
|
||||
mbfl_memory_device_init(&device, srclen + 1, 0);
|
||||
|
@ -410,14 +410,10 @@ MBSTRING_API char *php_unicode_convert_case(
|
|||
|
||||
mbfl_convert_filter_flush(to_wchar);
|
||||
mbfl_convert_filter_flush(from_wchar);
|
||||
result_ptr = mbfl_memory_device_result(&device, &result);
|
||||
mbfl_memory_device_result(&device, &result);
|
||||
mbfl_convert_filter_delete(to_wchar);
|
||||
mbfl_convert_filter_delete(from_wchar);
|
||||
|
||||
if (!result_ptr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ret_len = result.len;
|
||||
return (char *) result.val;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue