Skip to content

Commit e8ef24e

Browse files
committed
Fix alignment of 8-byte types
The correct alignment for bigint and friends is "double". On 64-bit machines that's 8 bytes. On 32-bit machines, architectures differ. On i386, it's 4 bytes, but on armel, armhf and powerpc it's 8 bytes. Follow-up for commit 476ddca where I not quite fixed it.
1 parent 888f5cd commit e8ef24e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

decode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ decode_uint(const char *buffer, unsigned int buff_size, unsigned int *out_size)
725725
static int
726726
decode_bigint(const char *buffer, unsigned int buff_size, unsigned int *out_size)
727727
{
728-
const char *new_buffer = (const char *) LONGALIGN(buffer);
728+
const char *new_buffer = (const char *) DOUBLEALIGN(buffer);
729729
unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
730730

731731
if (buff_size < delta)
@@ -746,7 +746,7 @@ decode_bigint(const char *buffer, unsigned int buff_size, unsigned int *out_size
746746
static int
747747
decode_time(const char *buffer, unsigned int buff_size, unsigned int *out_size)
748748
{
749-
const char *new_buffer = (const char *) LONGALIGN(buffer);
749+
const char *new_buffer = (const char *) DOUBLEALIGN(buffer);
750750
unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
751751
int64 timestamp,
752752
timestamp_sec;
@@ -775,7 +775,7 @@ decode_time(const char *buffer, unsigned int buff_size, unsigned int *out_size)
775775
static int
776776
decode_timetz(const char *buffer, unsigned int buff_size, unsigned int *out_size)
777777
{
778-
const char *new_buffer = (const char *) LONGALIGN(buffer);
778+
const char *new_buffer = (const char *) DOUBLEALIGN(buffer);
779779
unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
780780
int64 timestamp,
781781
timestamp_sec;
@@ -851,7 +851,7 @@ decode_date(const char *buffer, unsigned int buff_size, unsigned int *out_size)
851851
static int
852852
decode_timestamp_internal(const char *buffer, unsigned int buff_size, unsigned int *out_size, bool with_timezone)
853853
{
854-
const char *new_buffer = (const char *) LONGALIGN(buffer);
854+
const char *new_buffer = (const char *) DOUBLEALIGN(buffer);
855855
unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
856856
int64 timestamp,
857857
timestamp_sec;

0 commit comments

Comments
 (0)