avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiruvalluvan M. G. (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-47) Byte sequence to be represented as void*
Date Tue, 28 Jul 2009 04:07:14 GMT

    [ 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*.

string s("hello");
putBytes(&s, sizeof(s));

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.

View raw message