Release 980329
[wine/multimedia.git] / include / shm_fragment.h
blob893aee741cd045d98a55accff7fc09fb7ef0f347
1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
6 * File: shm_fragment.h
7 * Purpose: Data fragments and free list items. Allocate and free blocks.
8 ***************************************************************************
9 */
10 #ifndef __WINE_SHM_FRAGMENT_H
11 #define __WINE_SHM_FRAGMENT_H
13 #ifdef CONFIG_IPC
15 #include "shm_block.h"
17 #define NIL ((int) 0)
18 /* memory fragment: used or free (when free - it's an item of "free list",
19 * when allocated it contains the data, and it's size)
21 struct shm_fragment {
22 int size; /* fragment's size */
24 /* The type of info depends on fragment's status (free/allocated) */
25 union info {
26 int next; /* next free fragment */
27 char data[1]; /* the data */
28 } info;
31 /* setup first item in the free list */
32 void shm_FragmentInit(struct shm_block *block,REL_PTR first,int size);
34 /* allocate shm fragment. return: offset to data in fragment, or NULL */
35 REL_PTR shm_FragmentAlloc(struct shm_block *block, int size);
37 /* like shm_FragmentAlloc, returns pointer instead of offset */
38 char *shm_FragPtrAlloc(struct shm_block *block, int size);
40 /* free shm fragment - according to offset */
41 void shm_FragmentFree(struct shm_block *block, int ofs);
43 /* free shm fragment - according to pointer */
44 void shm_FragPtrFree(struct shm_block *block, void *ptr);
46 /* This is used for debugging only */
47 void shm_print_free_list(struct shm_block *block);
49 #endif /* CONFIG_IPC */
51 #endif /* __WINE_SHM_FRAGMENT_H */