Mercurial > urweb
comparison src/c/urweb.c @ 2017:bcda3ae88677
Align to sizeof(void *) instead of fixed 4
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 28 May 2014 11:53:19 -0400 |
parents | 4a93f379c452 |
children | 6372a742ab04 cb74460f046a |
comparison
equal
deleted
inserted
replaced
2016:3ed2ee0815d2 | 2017:bcda3ae88677 |
---|---|
1257 } | 1257 } |
1258 | 1258 |
1259 static void align_heap(uw_context ctx) { | 1259 static void align_heap(uw_context ctx) { |
1260 size_t posn = ctx->heap.front - ctx->heap.start; | 1260 size_t posn = ctx->heap.front - ctx->heap.start; |
1261 | 1261 |
1262 if (posn % 4 != 0) { | 1262 if (posn % sizeof(void *) != 0) { |
1263 size_t bump = 4 - posn % 4; | 1263 size_t bump = sizeof(void *) - posn % sizeof(void *); |
1264 uw_check_heap(ctx, bump); | 1264 uw_check_heap(ctx, bump); |
1265 ctx->heap.front += bump; | 1265 ctx->heap.front += bump; |
1266 } | 1266 } |
1267 } | 1267 } |
1268 | 1268 |
1273 // return. | 1273 // return. |
1274 | 1274 |
1275 void *result; | 1275 void *result; |
1276 | 1276 |
1277 if (ctx->amInitializing) { | 1277 if (ctx->amInitializing) { |
1278 int error = posix_memalign(&result, 4, len); | 1278 int error = posix_memalign(&result, sizeof(void *), len); |
1279 | 1279 |
1280 if (!error) | 1280 if (!error) |
1281 return result; | 1281 return result; |
1282 else | 1282 else |
1283 uw_error(ctx, FATAL, "uw_malloc: posix_memalign() returns %d", error); | 1283 uw_error(ctx, FATAL, "uw_malloc: posix_memalign() returns %d", error); |