# linked list



## taz (Mar 11, 2013)

I need a a linked list for a project I have been working on for FreeBSD. Now I don't want to use some unnecessary dependencies like glib. And reading style(9) suggests using queue(3) as supposed to rolling my own. I'm just not sure is queue(3) for more for kernel space or is it ok if user land applications use it?


----------



## kpa (Mar 11, 2013)

They are all implemented as macros and I'm sure it's ok to use them in user land programs.


----------



## taz (Mar 11, 2013)

Thank you. I have been googling about queue(3) and it's mentiond that it is used "mainly in kernel" so I just wanted to check.


----------



## fonz (Mar 11, 2013)

The main reason for asking to use queue(3) in kernel space instead of rolling your own is probably that this way the entire kernel uses the same tried and tested code with a known interface instead of ending up with dozens of linked list implementations of varying quality and all with different interfaces and quirks. When doing development for FreeBSD itself you are strongly encouraged to use queue(3). When developing a third-party application (i.e. a port) you are of course pretty much free to do whatever you want. As @kpa said, queue(3) is just a bunch of macros so it's perfectly fine to use it in userland code as well, *but* it will not be portable to other systems (e.g. Linux) unless you provide the necessary header file (including its license) with your code.


----------

