Skip to content

Commit

Permalink
Fix sizeof(http_parser) assert
Browse files Browse the repository at this point in the history
The result should be 32 on both 32 bits and 64 bits x86 because of
struct padding.

Fixes: nodejs#507
PR-URL: nodejs#510
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
bnoordhuis committed Jul 10, 2020
1 parent e13b274 commit 4f15b7d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,13 @@ main (void)
printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version);

printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser));
assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + sizeof(void *));

#if defined(__i386__) || defined(__x86_64__)
/* Should be 32 on both 32 bits and 64 bits x86 because of struct padding,
* see https://github.com/nodejs/http-parser/issues/507.
*/
assert(sizeof(http_parser) == 32);
#endif

//// API
test_preserve_data();
Expand Down

0 comments on commit 4f15b7d

Please sign in to comment.