Re: Issue with free() for linked list implementation

2015-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/15 6:08 PM, Kitt wrote: On Friday, 3 April 2015 at 22:06:06 UTC, Namespace wrote: On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote: Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using

Re: Issue with free() for linked list implementation

2015-04-06 Thread Namespace via Digitalmars-d-learn
2. When you malloc, you use 'two.sizeof' and 'ten.sizeof'. Integers are 4 bytes, so you were allocating 4 bytes for each of these (not 2 or 10 bytes as is alluded to above). Yeah, my mistake. I saw the mistake but could not describe it correctly. :)

Re: Issue with free() for linked list implementation

2015-04-04 Thread bearophile via Digitalmars-d-learn
Namespace: I've written a straight forward linked list implementation here: https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection/linkedlist.d Even though I'm using the GC to manage memory, maybe it will help you. Good idea to link to some existing code. Here

Re: Issue with free() for linked list implementation

2015-04-04 Thread Namespace via Digitalmars-d-learn
On Saturday, 4 April 2015 at 09:05:03 UTC, bearophile wrote: Namespace: I've written a straight forward linked list implementation here: https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection/linkedlist.d Even though I'm using the GC to manage memory, maybe it

Issue with free() for linked list implementation

2015-04-03 Thread Kitt via Digitalmars-d-learn
Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using malloc and free, but I’m running into an exception when I attempt to call free. Here is a very minimal code sample to illustrate the issue: //

Re: Issue with free() for linked list implementation

2015-04-03 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 3 April 2015 at 22:08:52 UTC, Kitt wrote: Thanks for the help =) I guess I've been in C# land at work for way too long now, my low level C skills are evaporating! I've written a straight forward linked list implementation here:

Re: Issue with free() for linked list implementation

2015-04-03 Thread Namespace via Digitalmars-d-learn
On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote: Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using malloc and free, but I’m running into an exception when I attempt to call free. Here is a

Re: Issue with free() for linked list implementation

2015-04-03 Thread Kitt via Digitalmars-d-learn
On Friday, 3 April 2015 at 22:06:06 UTC, Namespace wrote: On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote: Hello. I’m trying to write my own version of a list that doesn’t rely on the garbage collector. I’m working on a very bare bones implementation using malloc and free, but I’m running

Re: Issue with free() for linked list implementation

2015-04-03 Thread Namespace via Digitalmars-d-learn
Wow, I can't even begin to explain how red my cheeks are right now. You're completely right; I have no idea what my head was thinking. Sure enough, call malloc with the correct type, and the error goes away =P Thanks for the help =) I guess I've been in C# land at work for way too long now,

Re: Issue with free() for linked list implementation

2015-04-03 Thread Namespace via Digitalmars-d-learn
On Friday, 3 April 2015 at 22:38:00 UTC, Gary Willoughby wrote: On Friday, 3 April 2015 at 22:08:52 UTC, Kitt wrote: Thanks for the help =) I guess I've been in C# land at work for way too long now, my low level C skills are evaporating! I've written a straight forward linked list