tags:

views:

73

answers:

2

I am using C NOT C++!

I know the C++ collections, but I was wondering if Microsoft has a C based List structure of some type, like the linux kernel provides, that I can use in a user mode project?

I would prefer not rolling my own.

+2  A: 

Only thing in the Windows API is interlocked singly linked lists, which are used via InterlockedPushEntrySList and InterlockedPopEntrySList .

For device drivers, there is LIST_ENTRY, but I am not sure if this can be pulled into user-mode.

Many algorithms books and websites contain implementations of linked lists that can easily be ported to C. Rolling your own is not too difficult.

Michael
A: 

reusable collections are tough in C, it just doesn't have the flexibility or metadata (how do you know when you are overflowing this array list and need to reallocate? How do will reallocate work if the rest of the code is using a custom alloc?

You can do it (you CAN do anything in c), but it gets abstract really fast.

On the other hand, creating a linked list in c yourself is downright fun. Arrays are already there, hashes are annoying but not impossible, trees are fun, ...

Also--people who think in c tend to be constantly optimizing. Setting every linked list operation behind a function call instead of just using this=this.next would probably disgust many of them (rightfully so).

Bill K
I am going to dust off some older code I wrote and see how bad it is. I may just spend a few hours writing a new one.
Casey