Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 12:06:58 UTC, Adam D. Ruppe wrote: Slicing and indexing are both allowed (actually, that's a way to disable bounds checking on an individual expression, see tip: http://arsdnet.net/this-week-in-d/dec-06.html ) on pointers, though it isn't considered @safe. Be

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 19:52:17 UTC, Era Scarecrow wrote: You can do that??? I thought slices weren't allowed on raw pointers. You just blew my mind away! Slicing and indexing are both allowed (actually, that's a way to disable bounds checking on an individual expression, see tip:

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 24 May 2016 20:58:14 + schrieb Gary Willoughby : > On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: > > On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: > >> I have a T* pointer to the start of a malloc'd chunk of > >> memory, the type T

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]? BTW, the

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 24, 2016 19:52:17 Era Scarecrow via Digitalmars-d-learn wrote: > On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: > > On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: > >> I have a T* pointer to the start of a malloc'd chunk of > >> memory, the type T

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]? Slice it:

Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Gary Willoughby via Digitalmars-d-learn
I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]?