diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-13 09:52:02 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-13 09:52:02 +0000 |
commit | 0a3fc5be05c3f19eaa637628c20ab49640ae1faf (patch) | |
tree | 4175fa54fef7bfedb1def557dc8cd995b4fc24ad | |
parent | d4c74738415fcc9f2d7941d4a03ddf2904b955ce (diff) | |
download | ruby-0a3fc5be05c3f19eaa637628c20ab49640ae1faf.tar.gz |
* transcode.c (rb_transcoding): align state field.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | transcode.c | 13 |
2 files changed, 12 insertions, 5 deletions
@@ -1,3 +1,7 @@ +Sat Sep 13 18:46:41 2008 Tanaka Akira <akr@fsij.org> + + * transcode.c (rb_transcoding): align state field. + Sat Sep 13 18:21:09 2008 Tanaka Akira <akr@fsij.org> * transcode.c (DECORATOR_P): renamed from SUPPLEMENTAL_CONVERSION. diff --git a/transcode.c b/transcode.c index 8bb5f7bede..4d1107ddc4 100644 --- a/transcode.c +++ b/transcode.c @@ -67,7 +67,10 @@ typedef struct rb_transcoding { unsigned char *ptr; /* length: max_output */ } writebuf; - void *state; /* opaque data for stateful encoding */ + union rb_transcoding_state_t { /* opaque data for stateful encoding */ + void *ptr; + double dummy_for_alignment; + } state; } rb_transcoding; #define TRANSCODING_READBUF(tc) \ ((tc)->transcoder->max_input <= sizeof((tc)->readbuf.ary) ? \ @@ -77,11 +80,11 @@ typedef struct rb_transcoding { ((tc)->transcoder->max_output <= sizeof((tc)->writebuf.ary) ? \ (tc)->writebuf.ary : \ (tc)->writebuf.ptr) -#define TRANSCODING_STATE_EMBED_MAX sizeof(void *) +#define TRANSCODING_STATE_EMBED_MAX sizeof(union rb_transcoding_state_t) #define TRANSCODING_STATE(tc) \ ((tc)->transcoder->state_size <= sizeof((tc)->state) ? \ (void *)&(tc)->state : \ - (tc)->state) + (tc)->state.ptr) typedef struct { struct rb_transcoding *tc; @@ -728,7 +731,7 @@ rb_transcoding_open_by_transcoder(const rb_transcoder *tr, int flags) tc->transcoder = tr; tc->flags = flags; if (TRANSCODING_STATE_EMBED_MAX < tr->state_size) - tc->state = xmalloc(tr->state_size); + tc->state.ptr = xmalloc(tr->state_size); if (tr->state_init_func) { (tr->state_init_func)(TRANSCODING_STATE(tc)); /* xxx: check return value */ } @@ -766,7 +769,7 @@ rb_transcoding_close(rb_transcoding *tc) (tr->state_fini_func)(TRANSCODING_STATE(tc)); /* check return value? */ } if (TRANSCODING_STATE_EMBED_MAX < tr->state_size) - xfree(tc->state); + xfree(tc->state.ptr); if (sizeof(tc->readbuf.ary) < tr->max_input) xfree(tc->readbuf.ptr); if (sizeof(tc->writebuf.ary) < tr->max_output) |