Changeset 677 for branches/1.3/utils.h


Ignore:
Timestamp:
2009-08-28T04:53:53+02:00 (6 years ago)
Author:
moo
Message:

merged r671 from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 671
  • branches/1.3/utils.h

    r641 r677  
    128128void xc_copy_internal_zend_constants(HashTable *target, HashTable *source);
    129129#endif
     130
     131#ifndef ZEND_ENGINE_2_3
     132size_t zend_dirname(char *path, size_t len);
     133long zend_atol(const char *str, int len);
     134#endif
     135
     136typedef struct {
     137    zend_uint size;
     138    zend_uint cnt;
     139    void *data;
     140} xc_vector_t;
     141
     142#define xc_vector_init(type, vector) do { \
     143    (vector)->cnt = 0;     \
     144    (vector)->size = 0;    \
     145    (vector)->data = NULL; \
     146} while (0)
     147
     148#define xc_vector_add(type, vector, value) do { \
     149    if ((vector)->cnt == (vector)->size) { \
     150        if ((vector)->size) { \
     151            (vector)->size <<= 1; \
     152            (vector)->data = erealloc((vector)->data, sizeof(type) * (vector)->size); \
     153        } \
     154        else { \
     155            (vector)->size = 8; \
     156            (vector)->data = emalloc(sizeof(type) * (vector)->size); \
     157        } \
     158    } \
     159    ((type *) (vector)->data)[(vector)->cnt++] = value; \
     160} while (0)
     161
     162static inline void *xc_vector_detach_impl(xc_vector_t *vector)
     163{
     164    void *data = vector->data;
     165    vector->data = NULL;
     166    vector->size = 0;
     167    vector->cnt = 0;
     168    return data;
     169}
     170
     171#define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(vector))
     172
     173static inline void xc_vector_free_impl(xc_vector_t *vector TSRMLS_DC)
     174{
     175    if (vector->data) {
     176        efree(vector->data);
     177    }
     178    vector->size = 0;
     179    vector->cnt = 0;
     180}
     181
     182#define xc_vector_free(type, vector) xc_vector_free_impl(vector TSRMLS_CC)
     183
     184>>>>>>> .merge-right.r671
Note: See TracChangeset for help on using the changeset viewer.