Skip to content
  • Debarshi Ray's avatar
    Don't steal the SPARQL string passed to photos_query_new · 6df0ff81
    Debarshi Ray authored
    It is not idiomatic for strings to transfer ownership when passed as
    input arguments to functions, unless the function is explitly named
    as such. eg., "take" functions.
    
    Transferring the ownership of the SPARQL string to the PhotosQuery
    struct did afford us some conveniences. eg., not having to free the
    string. However, in a following patch, PhotosQuery is going to be
    converted into a GObject. It will be even more non-idiomatic to
    retain the current behaviour, and a future port to g_auto* will take
    care of the extra lines of code needed to free the string.
    
    That leaves the possibility of memory fragmentation caused by the
    extra copy. However, one can't say if that's a real issue without
    actual measurements. We don't really create that many PhotosQuery
    instances. In any case, this will be assuaged in the following patch
    where PhotosQuery instances will be made reference counted. That will
    remove the need to copy the sparql and tag fields, and reduce
    fragmentation.
    6df0ff81