Release 950727
[wine/multimedia.git] / include / shm_fragment.h
blob81a4b66a371deabd827fcad88643957d258261d4
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 #include "shm_block.h"
15 #define NIL ((int) 0)
16 /* memory fragment: used or free (when free - it's an item of "free list",
17 * when allocated it contains the data, and it's size)
19 struct shm_fragment {
20 int size; /* fragment's size */
22 /* The type of info depends on fragment's status (free/allocated) */
23 union info {
24 int next; /* next free fragment */
25 char data[1]; /* the data */
26 } info;
29 /* setup first item in the free list */
30 void shm_FragmentInit(struct shm_block *block,REL_PTR first,int size);
32 /* allocate shm fragment. return: offset to data in fragment, or NULL */
33 REL_PTR shm_FragmentAlloc(struct shm_block *block, int size);
35 /* like shm_FragmentAlloc, returns pointer instead of offset */
36 char *shm_FragPtrAlloc(struct shm_block *block, int size);
38 /* free shm fragment - according to offset */
39 void shm_FragmentFree(struct shm_block *block, int ofs);
41 /* free shm fragment - according to pointer */
42 void shm_FragPtrFree(struct shm_block *block, void *ptr);
44 /* This is used for debugging only */
45 void shm_print_free_list(struct shm_block *block);
47 #endif /* __WINE_SHM_FRAGMENT_H */