From 2cff15d35e4ff862e6a0811ae9e509c3d3352514 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Mon, 18 May 2015 11:37:03 -0700 Subject: Updates from code review comments. --- upb/refcounted.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'upb/refcounted.c') 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; -- cgit v1.2.3