diff options
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/decode.cpp | 15 | ||||
-rw-r--r-- | TAO/tao/encode.cpp | 16 |
2 files changed, 22 insertions, 9 deletions
diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index eac7514c125..1f47acab9eb 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -678,7 +678,7 @@ TAO_Marshal_Struct::decode (CORBA::TypeCode_ptr tc, CORBA::TypeCode::traverse_status retval = CORBA::TypeCode::TRAVERSE_CONTINUE; CORBA::Boolean continue_decoding = CORBA::B_TRUE; CORBA::TypeCode_ptr param; - CORBA::Long size, alignment; + CORBA::Long size, alignment, align_offset; void *start_addr = (void *)data; @@ -701,9 +701,16 @@ TAO_Marshal_Struct::decode (CORBA::TypeCode_ptr tc, alignment = param->alignment (env); if (env.exception () == 0) { - data = (const void *)((ptr_arith_t) ptr_align_binary (data, alignment) + - (ptr_arith_t) ptr_align_binary (start_addr, alignment) - - (ptr_arith_t) start_addr); + align_offset = + (ptr_arith_t) ptr_align_binary (data, alignment) + - (ptr_arith_t) data + + (ptr_arith_t) ptr_align_binary (start_addr, alignment) + - (ptr_arith_t) start_addr; + // if both the start_addr and data are not aligned as per + // the alignment, we do not add the offset + data = (const void *) ((ptr_arith_t) data + + ((align_offset == alignment) ? + 0 : align_offset)); switch (param->kind_) { case CORBA::tk_null: diff --git a/TAO/tao/encode.cpp b/TAO/tao/encode.cpp index 6d8e8cc98bc..5a57ae0d17b 100644 --- a/TAO/tao/encode.cpp +++ b/TAO/tao/encode.cpp @@ -409,7 +409,7 @@ TAO_Marshal_Struct::encode (CORBA::TypeCode_ptr tc, CORBA::TypeCode::traverse_status retval = CORBA::TypeCode::TRAVERSE_CONTINUE; CORBA::Boolean continue_encoding = CORBA::B_TRUE; CORBA::TypeCode_ptr param; - CORBA::Long size, alignment; + CORBA::Long size, alignment, align_offset; void *start_addr = (void *)data; @@ -431,10 +431,16 @@ TAO_Marshal_Struct::encode (CORBA::TypeCode_ptr tc, alignment = param->alignment (env); if (env.exception () == 0) { - data = (const void *) - ((ptr_arith_t) ptr_align_binary (data, alignment) + - (ptr_arith_t) ptr_align_binary (start_addr, alignment) - - (ptr_arith_t) start_addr); + align_offset = + (ptr_arith_t) ptr_align_binary (data, alignment) + - (ptr_arith_t) data + + (ptr_arith_t) ptr_align_binary (start_addr, alignment) + - (ptr_arith_t) start_addr; + // if both the start_addr and data are not aligned as per + // the alignment, we do not add the offset + data = (const void *) ((ptr_arith_t) data + + ((align_offset == alignment) ? + 0 : align_offset)); switch (param->kind_) { case CORBA::tk_null: |