Skip to content

Commit 47a5320

Browse files
committed
Combine ideas
Co-authored-by: [email protected]
1 parent 65cfe26 commit 47a5320

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ext/standard/pack.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,14 @@ typedef ZEND_SET_ALIGNED(1, int unaligned_int);
7777
/* {{{ php_pack */
7878
static void php_pack(const zval *val, size_t size, php_pack_endianness endianness, char *output)
7979
{
80-
zend_long zl = zval_get_long(val);
80+
zend_ulong zl = zval_get_long(val);
8181

82-
const char *v = (const char *) &zl;
8382
if ((endianness == PHP_LITTLE_ENDIAN) != MACHINE_LITTLE_ENDIAN) {
8483
zl = PHP_LONG_BSWAP(zl);
85-
v += sizeof(zl) - size;
84+
zl >>= (sizeof(zl) - size) * 8;
8685
}
8786

88-
while (size-- > 0) {
89-
*output++ = *v++;
90-
}
87+
memcpy(output, (const char *) &zl, size);
9188
}
9289
/* }}} */
9390

0 commit comments

Comments
 (0)