Skip to content

Commit e64d2a2

Browse files
committed
Rename php_little2bigendian() => php_ntohl()
thanks to Joe Drago...
1 parent e8c2e83 commit e64d2a2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ext/standard/image.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,11 +1161,13 @@ static struct gfxinfo *php_handle_avif(php_stream * stream) {
11611161
}
11621162
/* }}} */
11631163

1164-
/* {{{ php_little2bigendian
1165-
* Reverse the bytes in a little-endian uint32, returning the big-endian equivalent.
1166-
* Adapted lovingly from libavif's read.c.
1164+
/* {{{ php_ntohl
1165+
* Convert a big-endian network uint32 to host order -
1166+
* which may be either little-endian or big-endian.
1167+
* Thanks to Rob Pike via Joe Drago:
1168+
* https://commandcenter.blogspot.nl/2012/04/byte-order-fallacy.html
11671169
*/
1168-
static uint32_t php_little2bigendian(val) {
1170+
static uint32_t php_ntohl(val) {
11691171
uint8_t data[4];
11701172

11711173
memcpy(&data, &val, sizeof(data));
@@ -1204,7 +1206,7 @@ static int php_is_image_avif(php_stream * stream) {
12041206
return 0;
12051207
}
12061208

1207-
header_size = php_little2bigendian(header_size_reversed);
1209+
header_size = php_ntohl(header_size_reversed);
12081210

12091211
// If the box type isn't "ftyp", it can't be an AVIF image.
12101212
if (php_stream_read(stream, box_type, 4) != 4) {

0 commit comments

Comments
 (0)