* Use of double pointer in linux kernel Hash list implementation
@ 2010-06-17 2:50 Balachandar
2010-06-17 3:32 ` Namhyung Kim
0 siblings, 1 reply; 4+ messages in thread
From: Balachandar @ 2010-06-17 2:50 UTC (permalink / raw)
To: kernelnewbies, linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]
Hi,
I am trying to understand Linux Kernel implementation of linked list and
hash table. A link to the implementation is
here<http://lxr.linux.no/linux+v2.6.34/include/linux/list.h>.
I understood the linked list implementation. But i am little confused of why
double pointers is being used in hlist (**pprev). Link for hlist is
here<http://lxr.linux.no/linux+v2.6.34/include/linux/list.h#L554>.
I understand that hlist is used in implementation of hash table since head
of the list requires only one pointer and it saves space. Why cant it be
done using single pointer (just *prev like the linked list)? Please help me.
Thanks,
Bala
[-- Attachment #2: Type: text/html, Size: 720 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Use of double pointer in linux kernel Hash list implementation
2010-06-17 2:50 Use of double pointer in linux kernel Hash list implementation Balachandar
@ 2010-06-17 3:32 ` Namhyung Kim
2010-06-17 14:34 ` Balachandar
0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2010-06-17 3:32 UTC (permalink / raw)
To: Balachandar; +Cc: kernelnewbies, linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
2010-06-16 (수), 22:50 -0400, Balachandar:
> Hi,
> I am trying to understand Linux Kernel implementation of linked list
> and hash table. A link to the implementation is here. I understood the
> linked list implementation. But i am little confused of why double
> pointers is being used in hlist (**pprev). Link for hlist is here. I
> understand that hlist is used in implementation of hash table since
> head of the list requires only one pointer and it saves space. Why
> cant it be done using single pointer (just *prev like the linked
> list)? Please help me.
>
>
> Thanks,
> Bala
IMHO **pprev is only needed for fast deletion and/or insertion.
--
Regards,
Namhyung Kim
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Use of double pointer in linux kernel Hash list implementation
2010-06-17 3:32 ` Namhyung Kim
@ 2010-06-17 14:34 ` Balachandar
2010-06-18 2:10 ` Namhyung Kim
0 siblings, 1 reply; 4+ messages in thread
From: Balachandar @ 2010-06-17 14:34 UTC (permalink / raw)
To: Namhyung Kim; +Cc: kernelnewbies, linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 888 bytes --]
On Wed, Jun 16, 2010 at 11:32 PM, Namhyung Kim <namhyung@gmail.com> wrote:
> 2010-06-16 (수), 22:50 -0400, Balachandar:
> > Hi,
> > I am trying to understand Linux Kernel implementation of linked list
> > and hash table. A link to the implementation is here. I understood the
> > linked list implementation. But i am little confused of why double
> > pointers is being used in hlist (**pprev). Link for hlist is here. I
> > understand that hlist is used in implementation of hash table since
> > head of the list requires only one pointer and it saves space. Why
> > cant it be done using single pointer (just *prev like the linked
> > list)? Please help me.
> >
> >
> > Thanks,
> > Bala
>
>
> IMHO **pprev is only needed for fast deletion and/or insertion.
>
>
>
>
My doubt is why not use *prev as it is used in list_head implementation
rather than **pprev.
[-- Attachment #2: Type: text/html, Size: 1403 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Use of double pointer in linux kernel Hash list implementation
2010-06-17 14:34 ` Balachandar
@ 2010-06-18 2:10 ` Namhyung Kim
0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2010-06-18 2:10 UTC (permalink / raw)
To: Balachandar; +Cc: kernelnewbies, linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 365 bytes --]
2010-06-17 (목), 10:34 -0400, Balachandar:
>
> My doubt is why not use *prev as it is used in list_head
> implementation rather than **pprev.
hlist is simple linked list so there is no need of *prev. **pprev is a
kind of hack and should not be accessed in the outside of hlist. If you
need *prev, just use list_head.
--
Regards,
Namhyung Kim
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-18 2:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17 2:50 Use of double pointer in linux kernel Hash list implementation Balachandar
2010-06-17 3:32 ` Namhyung Kim
2010-06-17 14:34 ` Balachandar
2010-06-18 2:10 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).