]> granicus.if.org Git - php/commitdiff
Macrify the common operation
authorAnatol Belski <ab@php.net>
Wed, 24 Jan 2018 17:21:24 +0000 (18:21 +0100)
committerAnatol Belski <ab@php.net>
Wed, 24 Jan 2018 17:35:40 +0000 (18:35 +0100)
Zend/zend_portability.h
ext/standard/string.c

index f89258e0d657e1287ef2af9c7503ce88f64a96e9..6901a75c434318f91d3901be0df4e7263c021273 100644 (file)
@@ -540,6 +540,9 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
 # define ZEND_SET_ALIGNED(alignment, decl) decl
 #endif
 
+#define ZEND_SLIDE_TO_ALIGNED(alignment, ptr) (((zend_uintptr_t)(ptr) + ((alignment)-1)) & ~((alignment)-1))
+#define ZEND_SLIDE_TO_ALIGNED16(ptr) ZEND_SLIDE_TO_ALIGNED(Z_UL(16), ptr)
+
 #endif /* ZEND_PORTABILITY_H */
 
 /*
index cd2b028741c029337a461d773ac0f3938850f3c4..02f78a4f0e072b09cffa757217ce70d26e74b461 100644 (file)
@@ -3922,7 +3922,7 @@ zend_string *php_addslashes_sse42(zend_string *str, int should_free)
        end = source + ZSTR_LEN(str);
 
        if (ZSTR_LEN(str) > 15) {
-               char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15);
+               char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source);
 
                if (UNEXPECTED(source != aligned)) {
                        do {
@@ -3997,7 +3997,7 @@ do_escape:
                }
                source += 16;
        } else if (end - source > 15) {
-               char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15);
+               char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source);
 
                if (source != aligned) {
                        do {