21
21
#include "zend_globals.h"
22
22
#include "zend_smart_str_public.h"
23
23
24
- #define smart_str_appends_ex (dest , src , what ) \
25
- smart_str_appendl_ex((dest), (src), strlen(src), (what))
26
- #define smart_str_appends (dest , src ) \
27
- smart_str_appendl((dest), (src), strlen(src))
28
- #define smart_str_extract (dest ) \
29
- smart_str_extract_ex((dest), 0)
30
- #define smart_str_trim_to_size (dest ) \
31
- smart_str_trim_to_size_ex((dest), 0)
32
- #define smart_str_extend (dest , len ) \
33
- smart_str_extend_ex((dest), (len), 0)
34
- #define smart_str_appendc (dest , c ) \
35
- smart_str_appendc_ex((dest), (c), 0)
36
- #define smart_str_appendl (dest , src , len ) \
37
- smart_str_appendl_ex((dest), (src), (len), 0)
38
- #define smart_str_append (dest , src ) \
39
- smart_str_append_ex((dest), (src), 0)
40
- #define smart_str_append_smart_str (dest , src ) \
41
- smart_str_append_smart_str_ex((dest), (src), 0)
42
- #define smart_str_sets (dest , src ) \
43
- smart_str_setl((dest), (src), strlen(src));
44
- #define smart_str_append_long (dest , val ) \
45
- smart_str_append_long_ex((dest), (val), 0)
46
- #define smart_str_append_unsigned (dest , val ) \
47
- smart_str_append_unsigned_ex((dest), (val), 0)
48
- #define smart_str_free (dest ) \
49
- smart_str_free_ex((dest), 0)
50
-
51
24
BEGIN_EXTERN_C ()
52
25
53
26
ZEND_API void ZEND_FASTCALL smart_str_erealloc (smart_str * str , size_t len );
@@ -87,6 +60,11 @@ static zend_always_inline char* smart_str_extend_ex(smart_str *dest, size_t len,
87
60
return ret ;
88
61
}
89
62
63
+ static inline char * smart_str_extend (smart_str * dest , size_t length )
64
+ {
65
+ return smart_str_extend_ex (dest , length , false);
66
+ }
67
+
90
68
static zend_always_inline void smart_str_free_ex (smart_str * str , bool persistent ) {
91
69
if (str -> s ) {
92
70
zend_string_release_ex (str -> s , persistent );
@@ -95,6 +73,11 @@ static zend_always_inline void smart_str_free_ex(smart_str *str, bool persistent
95
73
str -> a = 0 ;
96
74
}
97
75
76
+ static inline void smart_str_free (smart_str * str )
77
+ {
78
+ smart_str_free_ex (str , false);
79
+ }
80
+
98
81
static zend_always_inline void smart_str_0 (smart_str * str ) {
99
82
if (str -> s ) {
100
83
ZSTR_VAL (str -> s )[ZSTR_LEN (str -> s )] = '\0' ;
@@ -113,6 +96,11 @@ static zend_always_inline void smart_str_trim_to_size_ex(smart_str *str, bool pe
113
96
}
114
97
}
115
98
99
+ static inline void smart_str_trim_to_size (smart_str * dest )
100
+ {
101
+ smart_str_trim_to_size_ex (dest , false);
102
+ }
103
+
116
104
static zend_always_inline zend_string * smart_str_extract_ex (smart_str * str , bool persistent ) {
117
105
if (str -> s ) {
118
106
zend_string * res ;
@@ -126,6 +114,11 @@ static zend_always_inline zend_string *smart_str_extract_ex(smart_str *str, bool
126
114
}
127
115
}
128
116
117
+ static inline zend_string * smart_str_extract (smart_str * dest )
118
+ {
119
+ return smart_str_extract_ex (dest , false);
120
+ }
121
+
129
122
static zend_always_inline void smart_str_appendc_ex (smart_str * dest , char ch , bool persistent ) {
130
123
size_t new_len = smart_str_alloc (dest , 1 , persistent );
131
124
ZSTR_VAL (dest -> s )[new_len - 1 ] = ch ;
@@ -154,15 +147,54 @@ static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_lo
154
147
smart_str_appendl_ex (dest , result , buf + sizeof (buf ) - 1 - result , persistent );
155
148
}
156
149
150
+ static inline void smart_str_append_long (smart_str * dest , zend_long num )
151
+ {
152
+ smart_str_append_long_ex (dest , num , false);
153
+ }
154
+
157
155
static zend_always_inline void smart_str_append_unsigned_ex (smart_str * dest , zend_ulong num , bool persistent ) {
158
156
char buf [32 ];
159
157
char * result = zend_print_ulong_to_buf (buf + sizeof (buf ) - 1 , num );
160
158
smart_str_appendl_ex (dest , result , buf + sizeof (buf ) - 1 - result , persistent );
161
159
}
162
160
161
+ static inline void smart_str_append_unsigned (smart_str * dest , zend_ulong num )
162
+ {
163
+ smart_str_append_unsigned_ex (dest , num , false);
164
+ }
165
+
166
+ static inline void smart_str_appendl (smart_str * dest , const char * src , size_t length )
167
+ {
168
+ smart_str_appendl_ex (dest , src , length , false);
169
+ }
170
+ static inline void smart_str_appends_ex (smart_str * dest , const char * src , bool persistent )
171
+ {
172
+ smart_str_appendl_ex (dest , src , strlen (src ), persistent );
173
+ }
174
+ static inline void smart_str_appends (smart_str * dest , const char * src )
175
+ {
176
+ smart_str_appendl_ex (dest , src , strlen (src ), false);
177
+ }
178
+ static inline void smart_str_append (smart_str * dest , const zend_string * src )
179
+ {
180
+ smart_str_append_ex (dest , src , false);
181
+ }
182
+ static inline void smart_str_appendc (smart_str * dest , char ch )
183
+ {
184
+ smart_str_appendc_ex (dest , ch , false);
185
+ }
186
+ static inline void smart_str_append_smart_str (smart_str * dest , const smart_str * src )
187
+ {
188
+ smart_str_append_smart_str_ex (dest , src , false);
189
+ }
190
+
163
191
static zend_always_inline void smart_str_setl (smart_str * dest , const char * src , size_t len ) {
164
192
smart_str_free (dest );
165
193
smart_str_appendl (dest , src , len );
166
194
}
167
195
196
+ static inline void smart_str_sets (smart_str * dest , const char * src )
197
+ {
198
+ smart_str_setl (dest , src , strlen (src ));
199
+ }
168
200
#endif
0 commit comments