enhanced parsing getline

added qse_cstrdup()/qse_wcstrdup()/qse_mcstrdup()
This commit is contained in:
2012-10-28 14:46:37 +00:00
parent 4e92c0ef1c
commit 18ab6aaf8d
8 changed files with 781 additions and 755 deletions

View File

@ -1657,6 +1657,16 @@ void* qse_awk_reallocmem (
qse_size_t size /**< new block size in bytes */
);
/**
* The qse_awk_callocmem() function allocates a memory block of
* the size of @a size bytes and initializes it with 0.
* @return a pointer to a memory block on success, #QSE_NULL on failure
*/
void* qse_awk_callocmem (
qse_awk_t* awk, /**< awk */
qse_size_t size /**< size of memory to allocate in bytes */
);
/**
* The qse_awk_freemem() function frees dynamic memory allocated.
*/
@ -1668,7 +1678,8 @@ void qse_awk_freemem (
/**
* The qse_awk_strdup() function is used to duplicate a string using
* the memory manager used by the associated qse_awk_t instance.
* The new string should be freed using the qse_awk_free() function.
* The new string must be freed using the qse_awk_freemem() function when
* it's not needed any more.
*
* @return a pointer to a new string duplicated of @a s on success,
* #QSE_NULL on failure.
@ -1681,8 +1692,8 @@ qse_char_t* qse_awk_strdup (
/**
* The qse_awk_strxdup() function is used to duplicate a string whose length
* is as long as len characters using the memory manager used by the
* qse_awk_t instance. The new string should be freed using the qse_awk_free()
* function.
* qse_awk_t instance. The new string must be freed using the qse_awk_freemem()
* function it's not needed any more.
*
* @return a pointer to a new string duplicated of @a s on success,
* #QSE_NULL on failure.
@ -1693,6 +1704,19 @@ qse_char_t* qse_awk_strxdup (
qse_size_t len /**< string length */
);
/**
* The qse_awk_cstrdup() funcation duplicates @a str->len characters from a
* string pointed to by @str->ptr. The duplicated string must be freed with
* the qse_awk_freemem() function when it's not needed any more.
*
* @return pointer to a duplicated string on success,
* #QSE_NULL on failure.
*/
qse_char_t* qse_awk_cstrdup (
qse_awk_t* awk, /**< awk */
const qse_cstr_t* str /**< string */
);
/**
* The qse_awk_strxtolong() function converts a string to an integer.
*/
@ -2524,6 +2548,16 @@ void* qse_awk_rtx_reallocmem (
qse_size_t size /**< block size in bytes */
);
/**
* The qse_awk_rtx_callocmem() function allocates a memory block of
* the size of @a size bytes and initializes it with 0.
* @return a pointer to a memory block on success, #QSE_NULL on failure
*/
void* qse_awk_rtx_callocmem (
qse_awk_rtx_t* rtx, /**< runtime context */
qse_size_t size /**< block size in bytes */
);
/**
* The qse_awk_rtx_freemem() function frees a memory block pointed to by @a ptr
* using the memory manager of a runtime ocntext @a rtx.

View File

@ -998,12 +998,6 @@ qse_mchar_t* qse_mbsadup (
qse_mmgr_t* mmgr
);
qse_mchar_t* qse_mbsxadup (
const qse_mcstr_t str[],
qse_size_t* len,
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_wcsdup (
const qse_wchar_t* str,
qse_mmgr_t* mmgr
@ -1035,26 +1029,48 @@ qse_wchar_t* qse_wcsadup (
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_wcsxadup (
const qse_wcstr_t str[],
qse_size_t* len,
qse_mmgr_t* mmgr
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strdup(s,mmgr) qse_mbsdup(s,mmgr)
# define qse_strdup2(s1,s2,mmgr) qse_mbsdup2(s1,s2,mmgr)
# define qse_strxdup(s,l,mmgr) qse_mbsxdup(s,l,mmgr)
# define qse_strxdup2(s1,l1,s2,l2,mmgr) qse_mbsxdup(s1,l1,s2,l2,mmgr)
# define qse_stradup(sa,len,mmgr) qse_mbsadup(sa,len,mmgr)
# define qse_strxadup(sa,len,mmgr) qse_mbsxadup(sa,len,mmgr)
#else
# define qse_strdup(s,mmgr) qse_wcsdup(s,mmgr)
# define qse_strdup2(s1,s2,mmgr) qse_wcsdup2(s1,s2,mmgr)
# define qse_strxdup(s,l,mmgr) qse_wcsxdup(s,l,mmgr)
# define qse_strxdup2(s1,l1,s2,l2,mmgr) qse_wcsxdup(s1,l1,s2,l2,mmgr)
# define qse_stradup(sa,len,mmgr) qse_wcsadup(sa,len,mmgr)
# define qse_strxadup(sa,len,mmgr) qse_wcsxadup(sa,len,mmgr)
#endif
qse_mchar_t* qse_mcstrdup (
const qse_mcstr_t* str,
qse_mmgr_t* mmgr
);
qse_mchar_t* qse_mcstradup (
const qse_mcstr_t str[],
qse_size_t* len,
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_wcstrdup (
const qse_wcstr_t* str,
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_wcstradup (
const qse_wcstr_t str[],
qse_size_t* len,
qse_mmgr_t* mmgr
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_cstrdup(sa,mmgr) qse_mcstrdup(sa,mmgr)
# define qse_cstradup(sa,len,mmgr) qse_mcstradup(sa,len,mmgr)
#else
# define qse_cstrdup(sa,mmgr) qse_wcstrdup(sa,mmgr)
# define qse_cstradup(sa,len,mmgr) qse_wcstradup(sa,len,mmgr)
#endif
/**