You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Thiruvalluvan M. G. (JIRA)" <ji...@apache.org> on 2009/07/28 06:07:14 UTC
[jira] Commented: (AVRO-47) Byte sequence to be represented as
void*
[ https://issues.apache.org/jira/browse/AVRO-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12735909#action_12735909 ]
Thiruvalluvan M. G. commented on AVRO-47:
-----------------------------------------
I think keeping uint8_t is more appropriate. void* in C++ means some unknown type at the given address. But here we expect 8-bit byte array and nothing else. For example, the following code, which is obviously incorrect, will not generate compiler error with void*.
{code:title=example}
string s("hello");
putBytes(&s, sizeof(s));
{code}
By requiring the caller to cast to uint8_t, we are forcing the developer to think if what he does is sane.
> Byte sequence to be represented as void*
> ----------------------------------------
>
> Key: AVRO-47
> URL: https://issues.apache.org/jira/browse/AVRO-47
> Project: Avro
> Issue Type: Bug
> Components: c++
> Reporter: Arvind Jayaprakash
> Attachments: AVRO-47
>
>
> The current function prototype for serializin bytes is as follows:
> void putBytes(const uint8_t *val, size_t size)
> This is better written as
> void putBytes(const void *val, size_t size)
> Using void* in favour of an int based data type frees us from unnecessary casting opaque bytes from arbitrary stuctures/classes into "integer". This is consistent with say a function like memcpy()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.