Hmm. This patch seems useful, however it introduces some memleaks
(the "result" of alpm_list_remove in vdata should be freed, and we
don't need strdup(pkg) here). After fixing these, this patch can be
applied imho.
Bye
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-22-2007, 01:52 PM
Nagy Gabor
Add remove counterparts to alpm_option_add_* functions
> Quick first thought here is these functions should not be void return
> type, but int so they can return whether they were successful or not.
> Of course, that provokes a second thought that notices that the list
> remove function has a rather odd function signature.
Well, I don't know. alpm_list_remove is one of our most reliable
functions, I cannot see any reason why it should fail (for example
alpm_list_add is not so reliable, because it must allocate some memory
for the new node header).
So if I understood correctly, you want to indicate whether the
to-be-removed element was found or not. I don't know if this is needed
or not, because as I said above we can guarantee, that if the
to-be-removed element exists, we remove it (one of them); and user
probably wants to remove an existing element.
But returning with your preferred integer doesn't hurt anything, so /me
shrugs.
> It looks like you could pass in a data pointer (set your vdata ptr to
> null first to be safe), and check after the remove call if something
> is in this pointer. If there was something, you actually have to free
> it (because of memory leak issues, which I just realized would
> happen). Finally, return true (1) if there was data returned, and
> false (0) if data was not found.
This data pointer is vdata in the patch (that's why I also said:
memleak).
> Thoughts from anyone else also welcome.
>
> -Dan
>
Bye
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-22-2007, 02:12 PM
Nagy Gabor
Add remove counterparts to alpm_option_add_* functions
> ... It looks like there is a
> leak in db.c with the "data" variable not being cleared.
That is cleared by _alpm_db_unregister(db); [Not very suggestive, I
know ;-). And usage of pointercmp instead of _alpm_db_cmp would be
safer here, indeed.]
Bye
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-23-2007, 01:43 AM
Allan McRae
Add remove counterparts to alpm_option_add_* functions
Updated patch attached without the memory leaks and adding return of
removal success.
Cheers,
Allan
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-23-2007, 11:50 AM
Nagy Gabor
Add remove counterparts to alpm_option_add_* functions
> Updated patch attached without the memory leaks and adding return of
> removal success.
>
> Cheers,
> Allan
Is newcachedir freed?;-)
Bye
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-23-2007, 09:39 PM
Allan McRae
Add remove counterparts to alpm_option_add_* functions
Nagy Gabor wrote:
Updated patch attached without the memory leaks and adding return of
removal success.
Cheers,
Allan
Is newcachedir freed?;-)
Bye
No... but it wasn't in alpm_option_add_cachedir() either and I was
trying for coding style consistency. Both are fixed in attached patch.
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-23-2007, 11:23 PM
Nagy Gabor
Add remove counterparts to alpm_option_add_* functions
> Nagy Gabor wrote:
> >> Updated patch attached without the memory leaks and adding return
> >> of removal success.
> >>
> >> Cheers,
> >> Allan
> >>
> >
> > Is newcachedir freed?;-)
> > Bye
> >
> >
> No... but it wasn't in alpm_option_add_cachedir() either and I was
> trying for coding style consistency. Both are fixed in attached
> patch.
No. You mustn't free it in add_cachedir, because alpm_list_add just adds
a POINTER to the (handle->cachedirs) list. (So you can always think
alpm_list as a list of pointers.)
Bye
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-23-2007, 11:50 PM
Allan McRae
Add remove counterparts to alpm_option_add_* functions
Dan McGee wrote:
On Dec 23, 2007 6:23 PM, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
No. You mustn't free it in add_cachedir, because alpm_list_add just adds
a POINTER to the (handle->cachedirs) list. (So you can always think
alpm_list as a list of pointers.)
Fixed in attachment. For some reason I thought there was a strdup in
the alpm_list_add statement but clearly there wasn't.
Ok, enough of this junk. Sorry to rain down on the holiday spirit, but
can we please not be cryptic on this mailing list with cute little
remarks and smiley faces?
Something like this would have saved us all 5 minutes of our time.
"I noticed that newcachedir was not freed in remove_cachedir- as far
as I can tell, it needs to be freed because we aren't adding it to a
list and it isn't needed outside of the function."
-Dan
Fair enough. This is probably the result of me being new to the code
base and making stupid trivial mistakes. However, point taken.
Allan
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-24-2007, 11:20 AM
Nagy Gabor
Add remove counterparts to alpm_option_add_* functions
> On Dec 23, 2007 6:23 PM, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
> > > Nagy Gabor wrote:
> > > >> Updated patch attached without the memory leaks and adding
> > > >> return of removal success.
> > > >>
> > > >> Cheers,
> > > >> Allan
> > > >>
> > > >
> > > > Is newcachedir freed?;-)
> > > > Bye
> > > >
> > > >
> > > No... but it wasn't in alpm_option_add_cachedir() either and I was
> > > trying for coding style consistency. Both are fixed in
> > > attached patch.
> > No. You mustn't free it in add_cachedir, because alpm_list_add just
> > adds a POINTER to the (handle->cachedirs) list. (So you can always
> > think alpm_list as a list of pointers.)
>
> Ok, enough of this junk. Sorry to rain down on the holiday spirit, but
> can we please not be cryptic on this mailing list with cute little
> remarks and smiley faces?
>
> Something like this would have saved us all 5 minutes of our time.
> "I noticed that newcachedir was not freed in remove_cachedir- as far
> as I can tell, it needs to be freed because we aren't adding it to a
> list and it isn't needed outside of the function."
>
> -Dan
>
1. If you refer to "Is newcachedir freed?;-)", then you should
have answered to my previous mail, because we had an _other_ bug here.
2. These "junks" were addressed to Allen, who fortunately understood
them. He is new to the code (as he said), and I thought he need other
information than you/us (alpm_list_t explanation). But if this is
forbidden here, next time I will write a direct e-mail to him or be
silent.
Merry Christmas!
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
12-24-2007, 12:13 PM
Allan McRae
Add remove counterparts to alpm_option_add_* functions
This should (hopefully) be the final incarnation of this patch... I
have removed even more of the unneeded strdup's that Nagy initially
pointed out.
Cheers,
Allan
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev