url.h icon indicating copy to clipboard operation
url.h copied to clipboard

Ownership issues

Open RokerHRO opened this issue 2 years ago • 2 comments

At the moment ownership aspects are completely undocumented, so I looked into the code:

  • url->href is a non-owning a shallow copy of the parameter given to url_parse() and not touched by the remaining code at all.
  • all other members of struct url_data are each heap-allocated copies, owned by the struct (and therefore free()'d in url_free()).

I'd like to know which property/behavior is as desired, which is just by coincidence and might be changed in a more optimized implementation (which I already have in mind, e.g. to support key-value access to the content of the query string, incl. percent decoding of non-ASCII data etc.) Different ownership would not affect clients/users that use the data read-only, but clients that changes the member would break.

RokerHRO avatar Jun 24 '23 19:06 RokerHRO

@RokerHRO I think if you have some good ideas about memory ownership, feel free to express them in a PR! I am highly confident it will be merged in :)

jwerle avatar Jun 26 '23 09:06 jwerle

@RokerHRO I think if you have some good ideas about memory ownership, feel free to express them in a PR! I am highly confident it will be merged in :)

I got some ideas and working on it. :-)

RokerHRO avatar Nov 08 '23 10:11 RokerHRO