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 05:38:14 GMT

    [ https://issues.apache.org/jira/browse/AVRO-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12735941#action_12735941

Thiruvalluvan M. G. commented on AVRO-47:

Hong, I agree it is inconveninet, but the price we pay seems too high as my example shows.

To quote Stroustrup (Sec 5.6 C++ Programming Language)
The primary use for void* is for passing pointers to functions that are not allowed to make
assumptions about the type of the object and for returning untyped objects from functions.
To use such an object, we must use explicit type conversion.

Functions using void* pointers typically exist at the very lowest level of the system, where
real hardware resources are manipulated.

The two are true for memXXX functions, but not us. Why? The data written using putBytes()
should be readable by programs written in another language and/or platform. We specifically
say that give me a sequence of bytes and we ensure that we read back the same sequence of
bytes in any language or platoform. On the other hand, memcpy says show me a portion of memory
I'll make a copy. This operation doesn't mean much outside C/C++ or the hardware platform.

> 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