Re: length = 0 clears reserve

2017-04-11 Thread Jon Degenhardt via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 20:00:48 UTC, Jethro wrote: On Tuesday, 11 April 2017 at 03:00:29 UTC, Jon Degenhardt wrote: On Tuesday, 11 April 2017 at 01:59:57 UTC, Jonathan M Davis wrote: On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: [...] You can't reuse the mem

Re: length = 0 clears reserve

2017-04-11 Thread Jethro via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 03:00:29 UTC, Jon Degenhardt wrote: On Tuesday, 11 April 2017 at 01:59:57 UTC, Jonathan M Davis wrote: On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: [...] You can't reuse the memory of a dynamic array by simply setting its length to 0.

Re: length = 0 clears reserve

2017-04-10 Thread Jon Degenhardt via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 01:59:57 UTC, Jonathan M Davis wrote: On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: arrays have the ability to reserve but when setting the length to 0, it removes the reserve!! ;/ char[] buf; buf.reserve = 1000; buf.length = 0; assert(b

Re: length = 0 clears reserve

2017-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: > arrays have the ability to reserve but when setting the length to > 0, it removes the reserve!! ;/ > > char[] buf; > buf.reserve = 1000; > buf.length = 0; > assert(buf.capacity == 0); > > But I simply want to clear the buff

length = 0 clears reserve

2017-04-10 Thread Jethro via Digitalmars-d-learn
arrays have the ability to reserve but when setting the length to 0, it removes the reserve!! ;/ char[] buf; buf.reserve = 1000; buf.length = 0; assert(buf.capacity == 0); But I simply want to clear the buffer, not change it's reserve/capacity. I've tried to hack by setting the length to 0 t