On Sat, 28 Aug 2010 16:13:28 -0400, BCS <n...@anon.com> wrote:

Hello Yao G.,

I'm here with another n00b question:
 When dealing with big buffers (or files), which is better to use as
storage? void[] or byte[]?

If the data may contain pointers into the heap, use void[] if it will not use byte[]. byte[] is "raw" data, void[] is anything at all.

One other point to make -- any type of array casts to void[]. So void[] is kind of like a "catch all" array type. It's typically the correct choice when accepting data that you are going to blindly copy somewhere. For example a function to write data to a file.

For reading data/storing data, the best type might be ubyte[] (don't use byte[], it's signed). void[] can also be used, but you may run into issues with "may contain pointers" problems.

I personally think the idea of allocating a void[] should set the "contains pointers" bit seems incorrect. Usually when a void[] contains pointers, it was not allocated as a void[].

-Steve

Reply via email to