From cb170d2e7adc54242f43bf8bab9a56f1dc5f2b2b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 16 Sep 2013 11:03:44 +0000 Subject: [PATCH] add QSE_XLI_PAIRXTNSIZE and qse_xli_getpairxtn() --- qse/include/qse/xli/xli.h | 8 +++++++- qse/lib/xli/xli.c | 17 +++++++++++++++-- qse/lib/xli/xli.h | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/qse/include/qse/xli/xli.h b/qse/include/qse/xli/xli.h index 60e628a7..823b96b8 100644 --- a/qse/include/qse/xli/xli.h +++ b/qse/include/qse/xli/xli.h @@ -72,7 +72,8 @@ typedef const qse_char_t* (*qse_xli_errstr_t) ( enum qse_xli_opt_t { - QSE_XLI_TRAIT + QSE_XLI_TRAIT, + QSE_XLI_PAIRXTNSIZE }; typedef enum qse_xli_opt_t qse_xli_opt_t; @@ -499,6 +500,11 @@ QSE_EXPORT void qse_xli_freemem ( void* ptr ); +QSE_EXPORT void* qse_xli_getpairxtn ( + qse_xli_t* xli, + qse_xli_pair_t* pair +); + QSE_EXPORT qse_xli_pair_t* qse_xli_insertpair ( qse_xli_t* xli, qse_xli_list_t* list, diff --git a/qse/lib/xli/xli.c b/qse/lib/xli/xli.c index ebf98f84..91862fc4 100644 --- a/qse/lib/xli/xli.c +++ b/qse/lib/xli/xli.c @@ -109,6 +109,10 @@ int qse_xli_setopt (qse_xli_t* xli, qse_xli_opt_t id, const void* value) case QSE_XLI_TRAIT: xli->opt.trait = *(const int*)value; return 0; + + case QSE_XLI_PAIRXTNSIZE: + xli->opt.pair_xtnsize = *(const qse_size_t*)value; + return 0; } qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); @@ -122,6 +126,10 @@ int qse_xli_getopt (qse_xli_t* xli, qse_xli_opt_t id, void* value) case QSE_XLI_TRAIT: *(int*)value = xli->opt.trait; return 0; + + case QSE_XLI_PAIRXTNSIZE: + *(qse_size_t*)value = xli->opt.pair_xtnsize; + return 0; }; qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); @@ -214,12 +222,12 @@ static qse_xli_pair_t* insert_pair ( alen = alias? alias->len: 0; pair = qse_xli_callocmem (xli, - QSE_SIZEOF(*pair) + + QSE_SIZEOF(*pair) + xli->opt.pair_xtnsize + ((key->len + 1) * QSE_SIZEOF(*key->ptr)) + ((alen + 1) * QSE_SIZEOF(*alias->ptr))); if (pair == QSE_NULL) return QSE_NULL; - kptr = (qse_char_t*)(pair + 1); + kptr = (qse_char_t*)((qse_uint8_t*)(pair + 1) + xli->opt.pair_xtnsize); qse_strcpy (kptr, key->ptr); pair->type = QSE_XLI_PAIR; @@ -236,6 +244,11 @@ static qse_xli_pair_t* insert_pair ( return pair; } +void* qse_xli_getpairxtn (qse_xli_t* xli, qse_xli_pair_t* pair) +{ + return (void*)(pair + 1); +} + qse_xli_pair_t* qse_xli_insertpair ( qse_xli_t* xli, qse_xli_list_t* parent, qse_xli_atom_t* peer, const qse_char_t* key, const qse_char_t* alias, qse_xli_val_t* value) diff --git a/qse/lib/xli/xli.h b/qse/lib/xli/xli.h index 57499bd6..722cdaea 100644 --- a/qse/lib/xli/xli.h +++ b/qse/lib/xli/xli.h @@ -54,7 +54,8 @@ struct qse_xli_t struct { - int trait; + int trait; + qse_size_t pair_xtnsize; } opt; qse_xli_ecb_t* ecb;