1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
7 * Purpose: Data fragments and free list items. Allocate and free blocks.
8 ***************************************************************************
10 #ifndef __WINE_SHM_FRAGMENT_H
11 #define __WINE_SHM_FRAGMENT_H
15 #include "shm_block.h"
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)
22 int size; /* fragment's size */
24 /* The type of info depends on fragment's status (free/allocated) */
26 int next; /* next free fragment */
27 char data[1]; /* the data */
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 */