According to:
https://github.com/freebsd/pkg/blob/d2ba38c68877e05ceb92eb372fb11e366198f895/docs/pkg_repos.3#L47

The binding should be `public static int repos(ref Repo? r);` and the
parameter should be initialised to null for the first iteration.

Your C program works because the stack happens to be zero when it starts,
but it is using undefined behaviour.

On 30 December 2016 at 11:13, Olivier Duchateau <duchateau.oliv...@gmail.com
> wrote:

> On Fri, 30 Dec 2016 14:48:27 +0000
> Luc Chante <luc.cha...@gmail.com> wrote:
>
> > Hello,
> >
> > I guess "Pkg.Repo" represents a single repo, so is it normal that
> > "Pkg.Repo.repos (out r)" isn't called on every iteration ?
>
> I've just tested and FreeBSD is displayed twice (instead of FreeBSD and
> Xfce).
>
> >
> > What was the tested condition in the while-loop ?
> > "while (Pkg.Status.OK == Pkg.Repo.repos (out r))"
>
> It causes an infinite loop (and core dump).
>
> >
> > Hope it helps.
> >
> > Le ven. 30 déc. 2016 à 15:24, Olivier Duchateau <
> duchateau.oliv...@gmail.com>
> > a écrit :
> >
> > > Hi,
> > >
> > > I'm trying to write Vala bindings for pkg(8), FreeBSD's packages
> manager.
> > > But I encounter weird behaviour in while loop.
> > >
> > > Currently I try to display name of repositories (FreeBSD and Xfce).
> > >
> > > My simple C program [1] works fine (expected result). If I use same
> while
> > > loop in my Vala program, I get an infinite loop. So I use for loop
> [2], but
> > > it's only FreeBSD which is displayed. I wonder how to iterate in loop.
> > >
> > > Traduction of related pkg_repo* methods is here [3], and corresponding
> C
> > > [4].
> > >
> > > Regards,
> > >
> > > [1]
> > > https://bitbucket.org/olivierduchateau/scripts/src/
> 1f34246a6bc9/pkg/repos.c?at=default
> > > [2]
> > > https://bitbucket.org/olivierduchateau/libpkg-vapi/
> src/cc552a344dac/test.vala?at=default
> > > [3]
> > > https://bitbucket.org/olivierduchateau/libpkg-vapi/
> src/cc552a344dac/pkg.vapi?at=default&fileviewer=file-view-
> default#pkg.vapi-146
> > > [4] https://github.com/freebsd/pkg/blob/1.9.4/libpkg/pkg.h.in#L1501
> > >
> > > --
> > > olivier
> > > _______________________________________________
> > > vala-list mailing list
> > > vala-list@gnome.org
> > > https://mail.gnome.org/mailman/listinfo/vala-list
> > >
> > _______________________________________________
> > vala-list mailing list
> > vala-list@gnome.org
> > https://mail.gnome.org/mailman/listinfo/vala-list
>
>
> --
> olivier
> _______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>



-- 
--Andre Masella<an...@masella.name>
http://www.masella.name/
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to