www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Setting a dynamic array from a pointer to data...

reply Paolo Invernizzi <arathorn NOSPAM_fastwebnet.it> writes:
Hi all,

I have a unsigned char* buffer from an external library that I know is 
sized, for example, 100.

What is the best way to turn it in a ubyte[] dynamic array?

Thanks

---
Paolo
Apr 03 2006
parent reply Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
Paolo Invernizzi skrev:
 Hi all,
 
 I have a unsigned char* buffer from an external library that I know is 
 sized, for example, 100.
 
 What is the best way to turn it in a ubyte[] dynamic array?

ubyte *buffer = whatever(); ubyte[] dynBuffer = buffer[0..100]; /Oskar
Apr 03 2006
parent reply Paolo Invernizzi <arathorn NOSPAM_fastwebnet.it> writes:
And no copy is appening I guess?

Oskar Linde wrote:
 Paolo Invernizzi skrev:
 Hi all,

 I have a unsigned char* buffer from an external library that I know is 
 sized, for example, 100.

 What is the best way to turn it in a ubyte[] dynamic array?

ubyte *buffer = whatever(); ubyte[] dynBuffer = buffer[0..100]; /Oskar

Apr 04 2006
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Paolo Invernizzi" <arathorn NOSPAM_fastwebnet.it> wrote in message 
news:e0tta5$17m2$1 digitaldaemon.com...
 And no copy is appening I guess?

Nope. It just sets the dynamic array's pointer to that data.
Apr 04 2006