*/
if (connection && connection->is_persistent && connection->is_stub) {
if (php_oci_create_session(connection, NULL, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, session_mode TSRMLS_CC)) {
- smart_str_free_ex(&hashed_details, 0);
+ smart_str_free(&hashed_details);
zend_hash_del(&EG(persistent_list), connection->hash_key);
return NULL;
++GC_REFCOUNT(connection->id);
}
}
- smart_str_free_ex(&hashed_details, 0);
+ smart_str_free(&hashed_details);
return connection;
}
}
/* server died */
} else {
/* we do not ping non-persistent connections */
- smart_str_free_ex(&hashed_details, 0);
+ smart_str_free(&hashed_details);
++GC_REFCOUNT(connection->id);
return connection;
}
if ((session_pool = php_oci_get_spool(username, username_len, password, password_len, dbname, dbname_len, charsetid ? charsetid:charsetid_nls_lang TSRMLS_CC))==NULL)
{
php_oci_connection_close(connection TSRMLS_CC);
- smart_str_free_ex(&hashed_details, 0);
+ smart_str_free(&hashed_details);
return NULL;
}
}
/* Mark password as unchanged by PHP during the duration of the database session */
connection->passwd_changed = 0;
- smart_str_free_ex(&hashed_details, 0);
+ smart_str_free(&hashed_details);
if (charsetid) {
connection->charset = charsetid;
}
exit_get_spool:
- smart_str_free_ex(&spool_hashed_details, 0);
+ smart_str_free(&spool_hashed_details);
if (iserror && session_pool) {
php_oci_spool_close(session_pool TSRMLS_CC);
session_pool = NULL;
#include <stdlib.h>
#include <zend.h>
-#define smart_str_0(x) do { \
- if ((x)->s) { \
- (x)->s->val[(x)->s->len] = '\0'; \
- } \
-} while (0)
-
#ifndef SMART_STR_PREALLOC
#define SMART_STR_PREALLOC 128
#endif
#define SMART_STR_START_SIZE 78
#endif
-#define smart_str_alloc4(d, n, what, newlen) do { \
- if (!(d)->s) { \
- newlen = (n); \
- (d)->a = newlen < SMART_STR_START_SIZE \
- ? SMART_STR_START_SIZE \
- : newlen + SMART_STR_PREALLOC; \
- (d)->s = zend_string_alloc((d)->a, (what)); \
- (d)->s->len = 0; \
- } else { \
- newlen = (d)->s->len + (n); \
- if (newlen >= (d)->a) { \
- (d)->a = newlen + SMART_STR_PREALLOC; \
- (d)->s = perealloc((d)->s, _STR_HEADER_SIZE + (d)->a + 1, (what)); \
- } \
- } \
-} while (0)
-
-#define smart_str_alloc(d, n, what) \
- smart_str_alloc4((d), (n), (what), newlen)
-
/* wrapper */
#define smart_str_appends_ex(dest, src, what) \
smart_str_appendl_ex((dest), (src), strlen(src), (what))
#define smart_str_appends(dest, src) \
smart_str_appendl((dest), (src), strlen(src))
-
#define smart_str_appendc(dest, c) \
smart_str_appendc_ex((dest), (c), 0)
-#define smart_str_free(s) \
- smart_str_free_ex((s), 0)
#define smart_str_appendl(dest, src, len) \
smart_str_appendl_ex((dest), (src), (len), 0)
#define smart_str_append(dest, src) \
smart_str_append_ex((dest), (src), 0)
+#define smart_str_sets(dest, src) \
+ smart_str_setl((dest), (src), strlen(src));
#define smart_str_append_long(dest, val) \
smart_str_append_long_ex((dest), (val), 0)
#define smart_str_append_off_t(dest, val) \
#define smart_str_append_unsigned(dest, val) \
smart_str_append_unsigned_ex((dest), (val), 0)
-#define smart_str_appendc_ex(dest, ch, what) do { \
- register size_t __nl; \
- smart_str_alloc4((dest), 1, (what), __nl); \
- (dest)->s->len = __nl; \
- ((unsigned char *) (dest)->s->val)[(dest)->s->len - 1] = (ch); \
-} while (0)
+static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zend_bool persistent) {
+ size_t newlen;
+ if (!str->s) {
+ newlen = len;
+ str->a = newlen < SMART_STR_START_SIZE
+ ? SMART_STR_START_SIZE
+ : newlen + SMART_STR_PREALLOC;
+ str->s = zend_string_alloc(str->a, persistent);
+ str->s->len = 0;
+ } else {
+ newlen = str->s->len + len;
+ if (newlen >= str->a) {
+ str->a = newlen + SMART_STR_PREALLOC;
+ str->s = perealloc(str->s, _STR_HEADER_SIZE + str->a + 1, persistent);
+ }
+ }
+ return newlen;
+}
-#define smart_str_free_ex(buf, what) do { \
- smart_str *__s = (smart_str *) (buf); \
- if (__s->s) { \
- zend_string_release(__s->s); \
- __s->s = NULL; \
- } \
- __s->a = 0; \
-} while (0)
+static zend_always_inline void smart_str_free(smart_str *str) {
+ if (str->s) {
+ zend_string_release(str->s);
+ str->s = NULL;
+ }
+ str->a = 0;
+}
-#define smart_str_appendl_ex(dest, src, nlen, what) do { \
- register size_t __nl; \
- smart_str *__dest = (smart_str *) (dest); \
- \
- smart_str_alloc4(__dest, (nlen), (what), __nl); \
- memcpy(__dest->s->val + __dest->s->len, (src), (nlen)); \
- __dest->s->len = __nl; \
-} while (0)
+static zend_always_inline void smart_str_0(smart_str *str) {
+ if (str->s) {
+ str->s->val[str->s->len] = '\0';
+ }
+}
-/*
- * these could be replaced using a braced-group inside an expression
- * for GCC compatible compilers, e.g.
- *
- * #define f(..) ({char *r;..;__r;})
- */
+static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) {
+ size_t new_len = smart_str_alloc(dest, 1, persistent);
+ dest->s->val[new_len - 1] = ch;
+ dest->s->len = new_len;
+}
+
+static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) {
+ size_t new_len = smart_str_alloc(dest, len, persistent);
+ memcpy(dest->s->val + dest->s->len, str, len);
+ dest->s->len = new_len;
+}
+
+static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_str *src, zend_bool persistent) {
+ if (src->s && src->s->len) {
+ smart_str_appendl_ex(dest, src->s->val, src->s->len, persistent);
+ }
+}
+
+static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
+ smart_str_free(dest);
+ smart_str_appendl(dest, src, len);
+}
static inline char *smart_str_print_long(char *buf, zend_long num) {
char *r;
#define smart_str_append_off_t_ex(dest, num, type) \
smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed)
-#define smart_str_append_ex(dest, src, what) do { \
- if ((src)->s && (src)->s->len) { \
- smart_str_appendl_ex((dest), (src)->s->val, (src)->s->len, (what)); \
- } \
-} while(0)
-
-#define smart_str_setl(dest, src, nlen) do { \
- smart_str_free((dest)); \
- smart_str_appendl_ex((dest), (src), (nlen), 0); \
-} while (0)
-
-#define smart_str_sets(dest, src) \
- smart_str_setl((dest), (src), strlen(src));
-
#endif