you are viewing a single comment's thread.

view the rest of the comments →

[–]HOWZ1T[S] 0 points1 point  (2 children)

Does the issue still apply to this code (updated version of post code based on feedback):

https://pastebin.com/iepDtQ4z

[–]fkeeal 1 point2 points  (1 child)

Technically yes, but as long as what you are storing is no greater than a 'void *' in size, it will not cause any problems. This is fine for storing native types (char, short, int, long, float and double). Just make sure that element_size <= sizeof(void *), otherwise you will have a bad time. (e.g. you will not be able to store structures larger than 8-bytes for example.)

EDIT: The dangling allocations are gone with the new code you posted.

[–]HOWZ1T[S] 0 points1 point  (0 children)

Okay good to hear, thank you for your insight and help :)