Moved datastore implementation into net_buffer.cpp - there is no reason to clobber the kernel with it.

This also fixes the issue of exporting a C++ API from the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18974 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-09-28 18:27:30 +00:00
parent 5af206180e
commit 02cc779b7d
4 changed files with 184 additions and 214 deletions
-27
View File
@@ -1,27 +0,0 @@
/* General data region of fixed size data blocks
*
* Copyright 2006, Haiku, Inc. All Rights Reserved
* Distributed under the terms of the MIT liscence.
*
* Authors:
* Andrew Galante, [email protected]
*/
struct datastore {
void *store; // ptr to data region
size_t blocksize; // size of the blocks in the datastore
size_t blockcount; // total number of blocks in the datastore
int32 *refcounts; // array containing refcounts for each block. a refcount of 0 is a free block
int lastfreed; // index of last freed block
int nextfree; // index of next free block
};
status_t init_datastore(struct datastore *store, size_t blocksize, int blockcount); // initializes the datastore
status_t uninit_datastore(struct datastore *store); // frees the memory used by the datastore
void *get_datablock(struct datastore *store); // returns a ptr to the first found free block, and increments its refcount
void *get_datablock(struct datastore *store, void *block); // increments the refcount of the specified block
status_t put_datablock(struct datastore *store, void *block); // decrements the refcount of the specified block
// not thread safe - for amusement purposes only:
int is_empty_datastore(struct datastore *store); // returns nonzero if all refcounts are zero
int is_full_datastore(struct datastore *store); // returns nonzero if all refcounts are greater than zero