[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pdf-devel] Public API and gl_list
From: |
gerel |
Subject: |
Re: [pdf-devel] Public API and gl_list |
Date: |
Mon, 10 Mar 2008 15:45:57 -0300 |
> Date: Mon, 10 Mar 2008 14:58:57 -0300
> From: <address@hidden>
>
> > Date: Mon, 10 Mar 2008 18:46:25 +0100
> > From: address@hidden
> >
> > Another issue is the function pointers,
> >
> > typedef bool (*gl_listelement_equals_fn) (const void *elt1, const void
> *elt2);
> > typedef size_t (*gl_listelement_hashcode_fn) (const void *elt);
> > typedef void (*gl_listelement_dispose_fn) (const void *elt);
> >
> > I think they're just fine for inclusion in pdf-list.h, don't you ?
> >
> > Yes. But it is much better to change the names of the callback types
> > to pdf_list_element_equals_fn, pdf_list_element_hashcode_fn and
> > pdf_list_element_dispose_fn.
> >
>
> Of course.
>
> -gerel
>
BTW, I'm thinking in declaring pdf_list_t, etc, to be a structure and not a
pointer to one, otherwise we'll need to change the list API. If we use pointers
we'll need to do memory allocation at the List module. :-S
Here's a sample code if we use pointers followed by the structure based version.
##
inline pdf_list_t
pdf_list_create (pdf_list_element_equals_fn_t equals_fn,
pdf_list_element_dispose_fn_t dispose_fn,
pdf_bool_t allow_duplicates)
{
pdf_list_t list;
list = pdf_alloc (sizeof(pdf_list_s));
if (list != NULL)
{
list->gl_list = gl_list_create_empty(GL_ARRAY_LIST, equals_fn, NULL,
dispose_fn, allow_duplicates);
}
else
{
pdf_perror (PDF_ENOMEM, "pdf_list_create()");
}
return (list);
}
###
##
inline pdf_list_t
pdf_list_create (pdf_list_element_equals_fn_t equals_fn,
pdf_list_element_dispose_fn_t dispose_fn,
pdf_bool_t allow_duplicates)
{
pdf_list_t list;
list->gl_list = gl_list_create_empty(GL_ARRAY_LIST, equals_fn, NULL,
dispose_fn, allow_duplicates);
return (list);
}
###
The same applies to pdf_list_node_t, pdf_list_iterator_t, etc.
I prefer the structure based version.
What do you think ?
-gerel
- Re: [pdf-devel] Public API and gl_list, (continued)
- Re: [pdf-devel] Public API and gl_list, Karl Berry, 2008/03/08
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/08
- Re: [pdf-devel] Public API and gl_list, Aleksander Morgado, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list,
gerel <=
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/10
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/11
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/11
- Re: [pdf-devel] Public API and gl_list, gerel, 2008/03/11
- Re: [pdf-devel] Public API and gl_list, jemarch, 2008/03/11