From b6e14c7be34c32090792d66d601f18ed356af342 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 23 Sep 2008 05:21:08 +0000 Subject: [PATCH] added the hint parameter to the sizer function --- ase/include/ase/cmn/str.h | 5 +++-- ase/include/ase/types.h | 4 ++-- ase/lib/cmn/str_dyn.c | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ase/include/ase/cmn/str.h b/ase/include/ase/cmn/str.h index eee2415c..bdaaf0a1 100644 --- a/ase/include/ase/cmn/str.h +++ b/ase/include/ase/cmn/str.h @@ -1,5 +1,5 @@ /* - * $Id: str.h 366 2008-09-04 11:15:53Z baconevi $ + * $Id: str.h 369 2008-09-22 11:21:08Z baconevi $ * * {License} */ @@ -237,7 +237,8 @@ ase_sizer_t ase_str_getsizer ( * DESCRIPTION: * The ase_str_setsizer() function specify a new sizer for a dynamic string. * With no sizer specified, the dynamic string doubles the current buffer - * when it needs to increase its size. + * when it needs to increase its size. The sizer function is passed a dynamic + * string and the minimum capacity required to hold data after resizing. */ void ase_str_setsizer ( ase_str_t* str /* a dynamic string */, diff --git a/ase/include/ase/types.h b/ase/include/ase/types.h index 742e1e17..0143691b 100644 --- a/ase/include/ase/types.h +++ b/ase/include/ase/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h 363 2008-09-04 10:58:08Z baconevi $ + * $Id: types.h 369 2008-09-22 11:21:08Z baconevi $ * * {License} */ @@ -360,6 +360,6 @@ struct ase_ccls_t * The ase_sizer_t is a generic type used by many other modules usually to * get the new size for resizing data structure. */ -typedef ase_size_t (*ase_sizer_t) (void* data); +typedef ase_size_t (*ase_sizer_t) (void* data, ase_size_t hint); #endif diff --git a/ase/lib/cmn/str_dyn.c b/ase/lib/cmn/str_dyn.c index ff28ae3e..cb579498 100644 --- a/ase/lib/cmn/str_dyn.c +++ b/ase/lib/cmn/str_dyn.c @@ -1,5 +1,5 @@ /* - * $Id: str_dyn.c 363 2008-09-04 10:58:08Z baconevi $ + * $Id: str_dyn.c 369 2008-09-22 11:21:08Z baconevi $ * * {License} */ @@ -210,8 +210,9 @@ ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len) } else { - /* let the user determine the new capacity */ - ncapa = str->sizer (str); + /* let the user determine the new capacity. + * pass the minimum capacity required as a hint */ + ncapa = str->sizer (str, str->size + len); } if (ase_str_setcapa (str, ncapa) == (ase_size_t)-1)