Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-14 Thread Nordlöw
On Wednesday, 8 July 2015 at 05:14:48 UTC, ketmar wrote: so while there is nothing wrong in creating slices from pointers, programmer should be aware of some potential pitfalls. I believe there's a DIP (involving the scope keyword) related to this problem, right?

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-14 Thread ketmar via Digitalmars-d-learn
On Tue, 14 Jul 2015 08:33:56 +, Nordlöw wrote: On Wednesday, 8 July 2015 at 05:14:48 UTC, ketmar wrote: so while there is nothing wrong in creating slices from pointers, programmer should be aware of some potential pitfalls. I believe there's a DIP (involving the scope keyword) related

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-09 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:26:33 UTC, Per Nordlöw wrote: I'm currently developing a high-level wrapper for FFMPEG at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d My question now becomes how to most easily wrap the iteration over streams at

Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread via Digitalmars-d-learn
I'm currently developing a high-level wrapper for FFMPEG at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d My question now becomes how to most easily wrap the iteration over streams at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d#L150

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/07/2015 12:26 a.m., Per =?UTF-8?B?Tm9yZGzDtnci?= per.nord...@gmail.com wrote: I'm currently developing a high-level wrapper for FFMPEG at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d My question now becomes how to most easily wrap the iteration over streams at

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:29:04 UTC, Rikki Cattermole wrote: size_t count; AVStream* thePtr; AVStream[] array = thePtr[0 .. count]; That should work. Thanks. Will that reuse the existing allocate memory at `thePtr` for internal storage of the D array? If so how is the GC aware of this

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread Rikki Cattermole via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:33:23 UTC, Per Nordlöw wrote: On Tuesday, 7 July 2015 at 12:29:04 UTC, Rikki Cattermole wrote: size_t count; AVStream* thePtr; AVStream[] array = thePtr[0 .. count]; That should work. Thanks. Will that reuse the existing allocate memory at `thePtr` for

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:36:11 UTC, Rikki Cattermole wrote: If you need to confirm that it is doing that, just @nogc it. If it allocates it'll fail. I could tag it as @nogc. Thx.

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:33:23 UTC, Per Nordlöw wrote: On Tuesday, 7 July 2015 at 12:29:04 UTC, Rikki Cattermole wrote: size_t count; AVStream* thePtr; AVStream[] array = thePtr[0 .. count]; That should work. Thanks. Will that reuse the existing allocate memory at `thePtr` for

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread ketmar via Digitalmars-d-learn
On Tue, 07 Jul 2015 12:36:09 +, Rikki Cattermole wrote: I'm not aware of much docs regarding these sort of tricks. But I believe it was Adam who originally discovered this little trick. Atleast I'm pretty sure he is how I learnt about it. On D.learn as well. i bet this trick was planned