Browse Source

merged r671 from trunk

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.3@677 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.3
Xuefer 12 years ago
parent
commit
22ef32e02f
  1. 40
      utils.c
  2. 55
      utils.h

40
utils.c

@ -839,3 +839,43 @@ int xc_trace(const char *fmt, ...) /* {{{ */
return ret;
}
/* }}} */
#ifndef ZEND_ENGINE_2_3
size_t zend_dirname(char *path, size_t len) /* {{{ */
{
php_dirname(path, len);
return strlen(path);
}
/* }}} */
long zend_atol(const char *str, int str_len) /* {{{ */
{
long retval;
if (!str_len) {
str_len = strlen(str);
}
retval = strtol(str, NULL, 0);
if (str_len > 0) {
switch (str[str_len - 1]) {
case 'g':
case 'G':
retval *= 1024;
/* break intentionally missing */
case 'm':
case 'M':
retval *= 1024;
/* break intentionally missing */
case 'k':
case 'K':
retval *= 1024;
break;
}
}
return retval;
}
/* }}} */
#endif

55
utils.h

@ -127,3 +127,58 @@ void xc_zend_constant_ctor(zend_constant *c);
void xc_zend_constant_dtor(zend_constant *c);
void xc_copy_internal_zend_constants(HashTable *target, HashTable *source);
#endif
#ifndef ZEND_ENGINE_2_3
size_t zend_dirname(char *path, size_t len);
long zend_atol(const char *str, int len);
#endif
typedef struct {
zend_uint size;
zend_uint cnt;
void *data;
} xc_vector_t;
#define xc_vector_init(type, vector) do { \
(vector)->cnt = 0; \
(vector)->size = 0; \
(vector)->data = NULL; \
} while (0)
#define xc_vector_add(type, vector, value) do { \
if ((vector)->cnt == (vector)->size) { \
if ((vector)->size) { \
(vector)->size <<= 1; \
(vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
} \
else { \
(vector)->size = 8; \
(vector)->data = emalloc(sizeof(type) * (vector)->size); \
} \
} \
((type *) (vector)->data)[(vector)->cnt++] = value; \
} while (0)
static inline void *xc_vector_detach_impl(xc_vector_t *vector)
{
void *data = vector->data;
vector->data = NULL;
vector->size = 0;
vector->cnt = 0;
return data;
}
#define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
{
if (vector->data) {
efree(vector->data);
}
vector->size = 0;
vector->cnt = 0;
}
#define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)
>>>>>>> .merge-right.r671

Loading…
Cancel
Save