~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to Zend/zend_mm.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   +----------------------------------------------------------------------+
 
3
   | Zend Engine                                                          |
 
4
   +----------------------------------------------------------------------+
 
5
   | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
 
6
   +----------------------------------------------------------------------+
 
7
   | This source file is subject to version 2.00 of the Zend license,     |
 
8
   | that is bundled with this package in the file LICENSE, and is        |
 
9
   | available through the world-wide-web at the following url:           |
 
10
   | http://www.zend.com/license/2_00.txt.                                |
 
11
   | If you did not receive a copy of the Zend license and are unable to  |
 
12
   | obtain it through the world-wide-web, please send a note to          |
 
13
   | license@zend.com so we can mail you a copy immediately.              |
 
14
   +----------------------------------------------------------------------+
 
15
   | Authors: Andi Gutmans <andi@zend.com>                                |
 
16
   |          Zeev Suraski <zeev@zend.com>                                |
 
17
   +----------------------------------------------------------------------+
 
18
*/
 
19
 
 
20
/* $Id: zend_mm.h,v 1.18 2004/07/05 17:06:41 andi Exp $ */
 
21
 
 
22
#ifndef _ZEND_MM_H
 
23
#define _ZEND_MM_H
 
24
 
 
25
#include <sys/types.h>
 
26
 
 
27
#include "zend.h"
 
28
#include "zend_types.h"
 
29
 
 
30
 
 
31
#ifdef ZEND_WIN32
 
32
#undef ZEND_MM
 
33
#else
 
34
/* #define ZEND_MM */
 
35
#undef ZEND_MM
 
36
#endif
 
37
 
 
38
/* mm block type */
 
39
typedef struct _zend_mm_block {
 
40
        unsigned int size : 31;
 
41
        unsigned int type : 1;
 
42
        size_t prev_size;
 
43
        unsigned int guard_block : 1;
 
44
} zend_mm_block;
 
45
 
 
46
typedef struct _zend_mm_free_block {
 
47
        unsigned int size : 31;
 
48
        unsigned int type : 1;
 
49
        size_t prev_size;
 
50
        struct _zend_mm_free_block *prev_free_block;
 
51
        struct _zend_mm_free_block *next_free_block;
 
52
} zend_mm_free_block;
 
53
 
 
54
typedef struct _zend_mm_segment {
 
55
        struct _zend_mm_segment *next_segment;
 
56
} zend_mm_segment;
 
57
 
 
58
#define ZEND_MM_NUM_BUCKETS 16
 
59
 
 
60
#define ZEND_HEAP_MAX_BUCKETS ZEND_MM_NUM_BUCKETS
 
61
 
 
62
typedef int zend_heap[2*ZEND_HEAP_MAX_BUCKETS-1];
 
63
 
 
64
typedef struct _zend_mm_heap {
 
65
        zend_mm_segment *segments_list;
 
66
        size_t block_size;
 
67
        zend_mm_free_block *free_buckets[ZEND_MM_NUM_BUCKETS];
 
68
        zend_heap heap;
 
69
} zend_mm_heap;
 
70
 
 
71
zend_bool zend_mm_startup(zend_mm_heap *heap, size_t block_size);
 
72
void zend_mm_shutdown(zend_mm_heap *heap);
 
73
void *zend_mm_alloc(zend_mm_heap *heap, size_t size);
 
74
void zend_mm_free(zend_mm_heap *heap, void *p);
 
75
void *zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size);
 
76
 
 
77
#endif /* _ZEND_MM_H */
 
78
 
 
79
/*
 
80
 * Local variables:
 
81
 * tab-width: 4
 
82
 * c-basic-offset: 4
 
83
 * indent-tabs-mode: t
 
84
 * End:
 
85
 */