SMFSW / Queue

Queue handling library (designed on Arduino)
BSD 3-Clause "New" or "Revised" License
97 stars 20 forks source link

free() in constructor? #3

Closed MikeGarber closed 6 years ago

MikeGarber commented 6 years ago

Line 37. Why? queue certainly isnt initialized to ANYTHING at that point.

SMFSW commented 6 years ago

I kept code as close as cQueue as possible (Cqueue is written in C, and as "constructor"/"destructor" are just simple functions in C, they can be called any time, causing memory leak if called twice, and getting fault when trying to free unallocated queue).

It shouldn't be initialized, I agree, and in case of multiple instantiations of a queue with same name, gcc generates warnings that shouldn't be ignored even if the code is linked in the end, and errors in the worst case.

Does it cause any issue (warning/error) in your case, or are you just wondering why it's there? If you're in the first case, please send me a skeleton of code that can generate such err/warning, I would be interested to see why. Thanks

I'll remove that line soon in the code.

SMFSW commented 6 years ago

Issue fixed in latest commit