On 7/25/17 8:40 AM, John Burton wrote:
I can create a "slice" using non-gc allocated memory.
int* ptr = cast(int*)calloc(int.sizeof, 10);
int[] data = ptr[0..10];
If I don't want a memory leak I have to call free(ptr) somewhere as it
won't be GC collected when data or ptr go
On Tuesday, 25 July 2017 at 13:24:36 UTC, Mike Parker wrote:
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote:
[...]
This should give you the answer:
writefln("Before: ptr = %s capacity = %s", slice.ptr,
slice.capacity);
slice ~= 1;
writefln("After: ptr = %s capacity = %s", slice
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote:
I can create a "slice" using non-gc allocated memory.
int* ptr = cast(int*)calloc(int.sizeof, 10);
int[] data = ptr[0..10];
If I don't want a memory leak I have to call free(ptr)
somewhere as it won't be GC collected
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote:
What happens? It seems to successfully append an extra value to
the array. It appears to "work" when I try it in my compiler
but I don't understand how. Will this be trying to write beyond
the memory I calloc'ed?
The language makes
I can create a "slice" using non-gc allocated memory.
int* ptr = cast(int*)calloc(int.sizeof, 10);
int[] data = ptr[0..10];
If I don't want a memory leak I have to call free(ptr) somewhere
as it won't be GC collected when data or ptr go out of scope. I
presume there is nothing