Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 123 lines (106 sloc) 3.241 kb
573b4602 »
1999-04-07 Zend Library
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
35e83d2a »
2010-01-05 sed -i "s#1998-2009#1998-2010#g" **/*.c **/*.h **/*.php
5 | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
573b4602 »
1999-04-07 Zend Library
6 +----------------------------------------------------------------------+
d863d52a »
2001-12-11 Update headers.
7 | This source file is subject to version 2.00 of the Zend license, |
2e5d0a3a »
2006-02-21 WS
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff2 »
2003-06-10 updating license information in the headers.
9 | available through the world-wide-web at the following url: |
d863d52a »
2001-12-11 Update headers.
10 | http://www.zend.com/license/2_00.txt. |
b5b11177 »
1999-07-16 License update
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. |
573b4602 »
1999-04-07 Zend Library
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
333406bd »
2003-02-01 - Added some missing CVS $Id$ tags, headers and footers.
20 /* $Id$ */
b5b11177 »
1999-07-16 License update
21
573b4602 »
1999-04-07 Zend Library
22 #include "zend.h"
23 #include "zend_ptr_stack.h"
009025e0 »
1999-09-06 * header file cleanup
24 #ifdef HAVE_STDARG_H
25 # include <stdarg.h>
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
26 #endif
573b4602 »
1999-04-07 Zend Library
27
fd54a536 »
2007-11-09 - Allow persistent zent_ptr_stacks (patch by Andrey Hristov)
28 ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent) /* {{{ */
573b4602 »
1999-04-07 Zend Library
29 {
fd54a536 »
2007-11-09 - Allow persistent zent_ptr_stacks (patch by Andrey Hristov)
30 stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent);
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
31 stack->max = PTR_STACK_BLOCK_SIZE;
573b4602 »
1999-04-07 Zend Library
32 stack->top = 0;
17f0bd9e »
2007-11-09 - That line got lost while merging around...
33 stack->persistent = persistent;
573b4602 »
1999-04-07 Zend Library
34 }
dd8af065 »
2007-07-11 fix folding, CS and WS
35 /* }}} */
573b4602 »
1999-04-07 Zend Library
36
fd54a536 »
2007-11-09 - Allow persistent zent_ptr_stacks (patch by Andrey Hristov)
37 ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack) /* {{{ */
38 {
39 zend_ptr_stack_init_ex(stack, 0);
40 }
41 /* }}} */
42
dd8af065 »
2007-07-11 fix folding, CS and WS
43 ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...) /* {{{ */
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
44 {
45 va_list ptr;
46 void *elem;
2e5d0a3a »
2006-02-21 WS
47
d7c839d5 »
2004-07-30 - More ptr_stack optimizations and cleanups
48 ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)
49
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
50 va_start(ptr, count);
51 while (count>0) {
52 elem = va_arg(ptr, void *);
53 stack->top++;
54 *(stack->top_element++) = elem;
55 count--;
56 }
57 va_end(ptr);
58 }
dd8af065 »
2007-07-11 fix folding, CS and WS
59 /* }}} */
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
60
dd8af065 »
2007-07-11 fix folding, CS and WS
61 ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...) /* {{{ */
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
62 {
63 va_list ptr;
64 void **elem;
2e5d0a3a »
2006-02-21 WS
65
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
66 va_start(ptr, count);
67 while (count>0) {
68 elem = va_arg(ptr, void **);
447eb3b0 »
1999-07-30 - Damn that's more like it.
69 *elem = *(--stack->top_element);
e9e7bc6d »
1999-07-30 - Add ptr_stack_n_{push,pop} in order to speed up function calls a bit.
70 stack->top--;
71 count--;
72 }
73 va_end(ptr);
74 }
dd8af065 »
2007-07-11 fix folding, CS and WS
75 /* }}} */
573b4602 »
1999-04-07 Zend Library
76
dd8af065 »
2007-07-11 fix folding, CS and WS
77 ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack) /* {{{ */
573b4602 »
1999-04-07 Zend Library
78 {
79 if (stack->elements) {
fd54a536 »
2007-11-09 - Allow persistent zent_ptr_stacks (patch by Andrey Hristov)
80 pefree(stack->elements, stack->persistent);
573b4602 »
1999-04-07 Zend Library
81 }
82 }
dd8af065 »
2007-07-11 fix folding, CS and WS
83 /* }}} */
573b4602 »
1999-04-07 Zend Library
84
dd8af065 »
2007-07-11 fix folding, CS and WS
85 ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *)) /* {{{ */
573b4602 »
1999-04-07 Zend Library
86 {
87 int i = stack->top;
88
89 while (--i >= 0) {
90 func(stack->elements[i]);
91 }
92 }
dd8af065 »
2007-07-11 fix folding, CS and WS
93 /* }}} */
573b4602 »
1999-04-07 Zend Library
94
dd8af065 »
2007-07-11 fix folding, CS and WS
95 ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements) /* {{{ */
573b4602 »
1999-04-07 Zend Library
96 {
97 zend_ptr_stack_apply(stack, func);
34c2b0a0 »
2000-06-17 - Add restore_error_handler()
98 if (free_elements) {
99 int i = stack->top;
100
101 while (--i >= 0) {
fd54a536 »
2007-11-09 - Allow persistent zent_ptr_stacks (patch by Andrey Hristov)
102 pefree(stack->elements[i], stack->persistent);
34c2b0a0 »
2000-06-17 - Add restore_error_handler()
103 }
104 }
573b4602 »
1999-04-07 Zend Library
105 stack->top = 0;
3fcc6511 »
1999-04-13 * Optimize argument_stack top lookup
106 stack->top_element = stack->elements;
573b4602 »
1999-04-07 Zend Library
107 }
dd8af065 »
2007-07-11 fix folding, CS and WS
108 /* }}} */
39a7f4c3 »
1999-04-12 This patch is a go. Not fully optimized yet, but working properly.
109
dd8af065 »
2007-07-11 fix folding, CS and WS
110 ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack) /* {{{ */
34c2b0a0 »
2000-06-17 - Add restore_error_handler()
111 {
112 return stack->top;
113 }
dd8af065 »
2007-07-11 fix folding, CS and WS
114 /* }}} */
333406bd »
2003-02-01 - Added some missing CVS $Id$ tags, headers and footers.
115
116 /*
117 * Local variables:
118 * tab-width: 4
119 * c-basic-offset: 4
120 * indent-tabs-mode: t
121 * End:
122 */
Something went wrong with that request. Please try again.