added the sizer function to ase_map_t

This commit is contained in:
2008-09-24 05:27:24 +00:00
parent 2230fbd445
commit 2fbbff8139
3 changed files with 43 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: str_dyn.c 372 2008-09-23 09:51:24Z baconevi $
* $Id: str_dyn.c 373 2008-09-23 11:27:24Z baconevi $
*
* {License}
*/
@ -213,6 +213,8 @@ ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len)
/* let the user determine the new capacity.
* pass the minimum capacity required as a hint */
ncapa = str->sizer (str, str->len + len);
/* if no change in capacity, return current length */
if (ncapa == str->capa) return str->len;
}
if (ase_str_setcapa (str, ncapa) == (ase_size_t)-1)
@ -223,7 +225,8 @@ ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len)
if (len > str->capa - str->len)
{
/* copy as many characters as the number of cells available */
/* copy as many characters as the number of cells available.
* if the capacity has been decreased, len is adjusted here */
len = str->capa - str->len;
}
@ -233,6 +236,7 @@ ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len)
str->len += len;
str->ptr[str->len] = ASE_T('\0');
}
return str->len;
}