diff options
author | Josh Haberman <jhaberman@gmail.com> | 2015-05-18 11:37:03 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2015-05-18 12:57:44 -0700 |
commit | 2cff15d35e4ff862e6a0811ae9e509c3d3352514 (patch) | |
tree | 3bc0d6ef00bf5a54011e72c38d544f47e908e83f /upb/refcounted.c | |
parent | e2840a4aa1b6a7a2ca1421d0d6da3e56992e5090 (diff) |
Updates from code review comments.
Diffstat (limited to 'upb/refcounted.c')
-rw-r--r-- | upb/refcounted.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/upb/refcounted.c b/upb/refcounted.c index 40e6e89..fa775ab 100644 --- a/upb/refcounted.c +++ b/upb/refcounted.c @@ -726,6 +726,18 @@ static void freeobj(upb_refcounted *o) { bool upb_refcounted_init(upb_refcounted *r, const struct upb_refcounted_vtbl *vtbl, const void *owner) { +#ifndef NDEBUG + // Endianness check. This is unrelated to upb_refcounted, it's just a + // convenient place to put the check that we can be assured will run for + // basically every program using upb. + const int x = 1; +#ifdef UPB_BIG_ENDIAN + assert(*(char*)&x != 1); +#else + assert(*(char*)&x == 1); +#endif +#endif + r->next = r; r->vtbl = vtbl; r->individual_count = 0; |