added the _instsize field to moo_t.

changed moo_getxtn() to utilize this new field.
remove moo_getxtnstd() as it's not needed any more for the added field
This commit is contained in:
hyunghwan.chung 2019-06-21 07:21:58 +00:00
parent 102de55322
commit 2cbfdfd6dd
10 changed files with 84 additions and 57 deletions

View File

@ -103,6 +103,34 @@ class MyObject(Object)
} }
*/ */
method(#class) test_quicksort: anArray
{
| quicksort |
quicksort := nil.
quicksort := [ :data :from :to |
(from < to)
ifTrue: [ | pivot index |
pivot := data at: from.
data swap: from with: to.
index := from.
from to: (to - 1) do: [ :each |
(data at: each) < pivot
ifTrue: [
data swap: each with: index.
index := index + 1
]
].
data swap: to with: index.
quicksort value: data value: from value: index - 1.
quicksort value: data value: index + 1 value: to
].
data
].
^(quicksort value: anArray value: 0 value: (anArray size - 1))
}
method(#class) main method(#class) main
{ {
| tc limit | | tc limit |
@ -114,6 +142,8 @@ class MyObject(Object)
[ self test_semaphore_heap == true ], [ self test_semaphore_heap == true ],
[ self test_mutex = #(2000 6000) ], [ self test_mutex = #(2000 6000) ],
####[ self test_sem_sig ], ####[ self test_sem_sig ],
[ (self test_quicksort: #(7 12 3 20 5 8 2) copy) = #(2 3 5 7 8 12 20)],
[ (self test_quicksort: %(99, 12, 18, 7, 12, 3, 20, 5, 8, 2)) = #(2 3 5 7 8 12 12 18 20 99)],
[ System sleepForSecs: 2. self.a == 300 ] ## sleep before checking self.a to prevent different result depending on process switching frequency and speed [ System sleepForSecs: 2. self.a == 300 ] ## sleep before checking self.a to prevent different result depending on process switching frequency and speed
). ).
@ -125,6 +155,8 @@ class MyObject(Object)
tb := tc at: idx. tb := tc at: idx.
System log(System.Log.INFO, idx asString, (if (tb value) { ' PASS' } else { ' FAIL' }), S'\n'). System log(System.Log.INFO, idx asString, (if (tb value) { ' PASS' } else { ' FAIL' }), S'\n').
]. ].
'AAAAAAAAAAAAAAAAAAAAAaa' dump.
} }
} }

View File

@ -9524,7 +9524,7 @@ oops:
prev = moo->c->curinp->includer; prev = moo->c->curinp->includer;
MOO_ASSERT (moo, moo->c->curinp->name != MOO_NULL); MOO_ASSERT (moo, moo->c->curinp->name != MOO_NULL);
MOO_MMGR_FREE (moo->mmgr, moo->c->curinp); moo_freemem (moo, moo->c->curinp);
moo->c->curinp = prev; moo->c->curinp = prev;
} }

View File

@ -225,7 +225,7 @@ static int err_bcs (moo_fmtout_t* fmtout, const moo_bch_t* ptr, moo_oow_t len)
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
if (max <= 0) return 1; if (max <= 0) return 1;
moo_conv_bchars_to_uchars_with_cmgr (ptr, &len, &moo->errmsg.buf[moo->errmsg.len], &max, moo->cmgr, 1); moo_conv_bchars_to_uchars_with_cmgr (ptr, &len, &moo->errmsg.buf[moo->errmsg.len], &max, moo_getcmgr(moo), 1);
moo->errmsg.len += max; moo->errmsg.len += max;
#else #else
if (len > max) len = max; if (len > max) len = max;
@ -253,7 +253,7 @@ static int err_ucs (moo_fmtout_t* fmtout, const moo_uch_t* ptr, moo_oow_t len)
moo->errmsg.len += len; moo->errmsg.len += len;
#else #else
if (max <= 0) return 1; if (max <= 0) return 1;
moo_conv_uchars_to_bchars_with_cmgr (ptr, &len, &moo->errmsg.buf[moo->errmsg.len], &max, moo->cmgr); moo_conv_uchars_to_bchars_with_cmgr (ptr, &len, &moo->errmsg.buf[moo->errmsg.len], &max, moo_getcmgr(moo));
moo->errmsg.len += max; moo->errmsg.len += max;
#endif #endif
moo->errmsg.buf[moo->errmsg.len] = '\0'; moo->errmsg.buf[moo->errmsg.len] = '\0';

View File

@ -1683,7 +1683,7 @@ static int log_ucs (moo_fmtout_t* fmtout, const moo_uch_t* ptr, moo_oow_t len)
{ {
len = rem; len = rem;
bcslen = MOO_COUNTOF(bcs); bcslen = MOO_COUNTOF(bcs);
moo_conv_uchars_to_bchars_with_cmgr(ptr, &len, bcs, &bcslen, moo->cmgr); moo_conv_uchars_to_bchars_with_cmgr(ptr, &len, bcs, &bcslen, moo_getcmgr(moo));
log_bcs(fmtout, bcs, bcslen); log_bcs(fmtout, bcs, bcslen);
rem -= len; rem -= len;
ptr += len; ptr += len;
@ -1707,7 +1707,7 @@ static int log_bcs (moo_fmtout_t* fmtout, const moo_bch_t* ptr, moo_oow_t len)
{ {
len = rem; len = rem;
ucslen = MOO_COUNTOF(ucs); ucslen = MOO_COUNTOF(ucs);
moo_conv_bchars_to_uchars_with_cmgr(ptr, &len, ucs, &ucslen, moo->cmgr, 1); moo_conv_bchars_to_uchars_with_cmgr(ptr, &len, ucs, &ucslen, moo_getcmgr(moo), 1);
log_ucs(fmtout, ucs, ucslen); log_ucs(fmtout, ucs, ucslen);
rem -= len; rem -= len;
ptr += len; ptr += len;
@ -1837,7 +1837,7 @@ static int sprint_bcs (moo_fmtout_t* fmtout, const moo_bch_t* ptr, moo_oow_t len
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
blen = len; blen = len;
moo_conv_bchars_to_uchars_with_cmgr (ptr, &blen, MOO_NULL, &oolen, moo->cmgr, 1); moo_conv_bchars_to_uchars_with_cmgr (ptr, &blen, MOO_NULL, &oolen, moo_getcmgr(moo), 1);
#else #else
oolen = len; oolen = len;
#endif #endif
@ -1858,7 +1858,7 @@ static int sprint_bcs (moo_fmtout_t* fmtout, const moo_bch_t* ptr, moo_oow_t len
} }
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
moo_conv_bchars_to_uchars_with_cmgr (ptr, &len, &moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], &oolen, moo->cmgr, 1); moo_conv_bchars_to_uchars_with_cmgr (ptr, &len, &moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], &oolen, moo_getcmgr(moo), 1);
#else #else
MOO_MEMCPY (&moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], ptr, len * MOO_SIZEOF(*ptr)); MOO_MEMCPY (&moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], ptr, len * MOO_SIZEOF(*ptr));
#endif #endif
@ -1878,7 +1878,7 @@ static int sprint_ucs (moo_fmtout_t* fmtout, const moo_uch_t* ptr, moo_oow_t len
oolen = len; oolen = len;
#else #else
ulen = len; ulen = len;
moo_conv_uchars_to_bchars_with_cmgr (ptr, &ulen, MOO_NULL, &oolen, moo->cmgr); moo_conv_uchars_to_bchars_with_cmgr (ptr, &ulen, MOO_NULL, &oolen, moo_getcmgr(moo));
#endif #endif
if (oolen > unused) if (oolen > unused)
@ -1899,7 +1899,7 @@ static int sprint_ucs (moo_fmtout_t* fmtout, const moo_uch_t* ptr, moo_oow_t len
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
MOO_MEMCPY (&moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], ptr, len * MOO_SIZEOF(*ptr)); MOO_MEMCPY (&moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], ptr, len * MOO_SIZEOF(*ptr));
#else #else
moo_conv_uchars_to_bchars_with_cmgr (ptr, &len, &moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], &oolen, moo->cmgr); moo_conv_uchars_to_bchars_with_cmgr (ptr, &len, &moo->sprintf.xbuf.ptr[moo->sprintf.xbuf.len], &oolen, moo_getcmgr(moo));
#endif #endif
moo->sprintf.xbuf.len += oolen; moo->sprintf.xbuf.len += oolen;

View File

@ -104,10 +104,6 @@ MOO_EXPORT moo_t* moo_openstd (
moo_errinf_t* errinfo moo_errinf_t* errinfo
); );
MOO_EXPORT void* moo_getxtnstd (
moo_t* moo
);
MOO_EXPORT void moo_abortstd ( MOO_EXPORT void moo_abortstd (
moo_t* moo moo_t* moo
); );

View File

@ -56,7 +56,7 @@ moo_t* moo_open (moo_mmgr_t* mmgr, moo_oow_t xtnsize, moo_cmgr_t* cmgr, const mo
void moo_close (moo_t* moo) void moo_close (moo_t* moo)
{ {
moo_fini (moo); moo_fini (moo);
MOO_MMGR_FREE (moo->mmgr, moo); MOO_MMGR_FREE (moo_getmmgr(moo), moo);
} }
static void fill_bigint_tables (moo_t* moo) static void fill_bigint_tables (moo_t* moo)
@ -86,16 +86,14 @@ static void fill_bigint_tables (moo_t* moo)
} }
} }
static void* alloc_heap (moo_t* moo, moo_oow_t size) static MOO_INLINE void* alloc_heap (moo_t* moo, moo_oow_t size)
{ {
void* ptr = MOO_MMGR_ALLOC(moo->mmgr, size); return moo_allocmem(moo, size);
if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM);
return ptr;
} }
static void free_heap (moo_t* moo, void* ptr) static MOO_INLINE void free_heap (moo_t* moo, void* ptr)
{ {
MOO_MMGR_FREE(moo->mmgr, ptr); moo_freemem (moo, ptr);
} }
int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_cmgr_t* cmgr, const moo_vmprim_t* vmprim) int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_cmgr_t* cmgr, const moo_vmprim_t* vmprim)
@ -109,8 +107,10 @@ int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_cmgr_t* cmgr, const moo_vmprim_t
} }
MOO_MEMSET (moo, 0, MOO_SIZEOF(*moo)); MOO_MEMSET (moo, 0, MOO_SIZEOF(*moo));
moo->mmgr = mmgr; moo->_instsize = MOO_SIZEOF(*moo);
moo->cmgr = cmgr; moo->_mmgr = mmgr;
moo->_cmgr = cmgr;
moo->vmprim = *vmprim; moo->vmprim = *vmprim;
if (!moo->vmprim.alloc_heap) moo->vmprim.alloc_heap = alloc_heap; if (!moo->vmprim.alloc_heap) moo->vmprim.alloc_heap = alloc_heap;
if (!moo->vmprim.free_heap) moo->vmprim.free_heap = free_heap; if (!moo->vmprim.free_heap) moo->vmprim.free_heap = free_heap;
@ -427,7 +427,7 @@ void* moo_allocmem (moo_t* moo, moo_oow_t size)
{ {
void* ptr; void* ptr;
ptr = MOO_MMGR_ALLOC (moo->mmgr, size); ptr = MOO_MMGR_ALLOC(moo_getmmgr(moo), size);
if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM); if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM);
return ptr; return ptr;
} }
@ -436,7 +436,7 @@ void* moo_callocmem (moo_t* moo, moo_oow_t size)
{ {
void* ptr; void* ptr;
ptr = MOO_MMGR_ALLOC (moo->mmgr, size); ptr = MOO_MMGR_ALLOC(moo_getmmgr(moo), size);
if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM); if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM);
else MOO_MEMSET (ptr, 0, size); else MOO_MEMSET (ptr, 0, size);
return ptr; return ptr;
@ -444,14 +444,14 @@ void* moo_callocmem (moo_t* moo, moo_oow_t size)
void* moo_reallocmem (moo_t* moo, void* ptr, moo_oow_t size) void* moo_reallocmem (moo_t* moo, void* ptr, moo_oow_t size)
{ {
ptr = MOO_MMGR_REALLOC (moo->mmgr, ptr, size); ptr = MOO_MMGR_REALLOC (moo_getmmgr(moo), ptr, size);
if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM); if (!ptr) moo_seterrnum (moo, MOO_ESYSMEM);
return ptr; return ptr;
} }
void moo_freemem (moo_t* moo, void* ptr) void moo_freemem (moo_t* moo, void* ptr)
{ {
MOO_MMGR_FREE (moo->mmgr, ptr); MOO_MMGR_FREE (moo_getmmgr(moo), ptr);
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */

View File

@ -1351,8 +1351,9 @@ typedef struct moo_errinf_t moo_errinf_t;
struct moo_t struct moo_t
{ {
moo_mmgr_t* mmgr; moo_oow_t _instsize;
moo_cmgr_t* cmgr; moo_mmgr_t* _mmgr;
moo_cmgr_t* _cmgr;
moo_errnum_t errnum; moo_errnum_t errnum;
struct struct
{ {
@ -1844,19 +1845,19 @@ MOO_EXPORT void moo_fini (
); );
#if defined(MOO_HAVE_INLINE) #if defined(MOO_HAVE_INLINE)
static MOO_INLINE moo_mmgr_t* moo_getmmgr (moo_t* moo) { return moo->mmgr; } static MOO_INLINE moo_mmgr_t* moo_getmmgr (moo_t* moo) { return moo->_mmgr; }
static MOO_INLINE void* moo_getxtn (moo_t* moo) { return (void*)(moo + 1); } static MOO_INLINE void* moo_getxtn (moo_t* moo) { return (void*)((moo_uint8_t*)moo + moo->_instsize); }
static MOO_INLINE moo_cmgr_t* moo_getcmgr (moo_t* moo) { return moo->cmgr; } static MOO_INLINE moo_cmgr_t* moo_getcmgr (moo_t* moo) { return moo->_cmgr; }
static MOO_INLINE void moo_setcmgr (moo_t* moo, moo_cmgr_t* cmgr) { moo->cmgr = cmgr; } static MOO_INLINE void moo_setcmgr (moo_t* moo, moo_cmgr_t* cmgr) { moo->_cmgr = cmgr; }
static MOO_INLINE moo_errnum_t moo_geterrnum (moo_t* moo) { return moo->errnum; } static MOO_INLINE moo_errnum_t moo_geterrnum (moo_t* moo) { return moo->errnum; }
#else #else
# define moo_getmmgr(moo) (((moo_t*)(moo))->mmgr) # define moo_getmmgr(moo) (((moo_t*)(moo))->_mmgr)
# define moo_getxtn(moo) ((void*)((moo_t*)(moo) + 1)) # define moo_getxtn(moo) ((void*)((moo_uint8_t*)moo + ((moo_t*)moo)->_instsize))
# define moo_getcmgr(moo) (((moo_t*)(moo))->cmgr) # define moo_getcmgr(moo) (((moo_t*)(moo))->_cmgr)
# define moo_setcmgr(moo,mgr) (((moo_t*)(moo))->cmgr = (mgr)) # define moo_setcmgr(moo,cmgr) (((moo_t*)(moo))->_cmgr = (cmgr))
# define moo_geterrnum(moo) (((moo_t*)(moo))->errnum) # define moo_geterrnum(moo) (((moo_t*)(moo))->errnum)
#endif #endif

View File

@ -67,8 +67,8 @@ MOO_INLINE moo_rbt_pair_t* moo_rbt_allocpair (
if (kcop == MOO_RBT_COPIER_INLINE) as += MOO_ALIGN_POW2(KTOB(rbt,klen), MOO_SIZEOF_VOID_P); if (kcop == MOO_RBT_COPIER_INLINE) as += MOO_ALIGN_POW2(KTOB(rbt,klen), MOO_SIZEOF_VOID_P);
if (vcop == MOO_RBT_COPIER_INLINE) as += VTOB(rbt,vlen); if (vcop == MOO_RBT_COPIER_INLINE) as += VTOB(rbt,vlen);
pair = (moo_rbt_pair_t*) MOO_MMGR_ALLOC (rbt->moo->mmgr, as); pair = (moo_rbt_pair_t*)moo_allocmem(rbt->moo, as);
if (pair == MOO_NULL) return MOO_NULL; if (!pair) return MOO_NULL;
pair->color = MOO_RBT_RED; pair->color = MOO_RBT_RED;
pair->parent = MOO_NULL; pair->parent = MOO_NULL;
@ -90,7 +90,7 @@ MOO_INLINE moo_rbt_pair_t* moo_rbt_allocpair (
KPTR(pair) = kcop(rbt, kptr, klen); KPTR(pair) = kcop(rbt, kptr, klen);
if (KPTR(pair) == MOO_NULL) if (KPTR(pair) == MOO_NULL)
{ {
MOO_MMGR_FREE (rbt->moo->mmgr, pair); moo_freemem (rbt->moo, pair);
return MOO_NULL; return MOO_NULL;
} }
} }
@ -114,7 +114,7 @@ MOO_INLINE moo_rbt_pair_t* moo_rbt_allocpair (
{ {
if (rbt->style->freeer[MOO_RBT_KEY] != MOO_NULL) if (rbt->style->freeer[MOO_RBT_KEY] != MOO_NULL)
rbt->style->freeer[MOO_RBT_KEY] (rbt, KPTR(pair), KLEN(pair)); rbt->style->freeer[MOO_RBT_KEY] (rbt, KPTR(pair), KLEN(pair));
MOO_MMGR_FREE (rbt->moo->mmgr, pair); moo_freemem (rbt->moo, pair);
return MOO_NULL; return MOO_NULL;
} }
} }
@ -128,7 +128,7 @@ MOO_INLINE void moo_rbt_freepair (moo_rbt_t* rbt, moo_rbt_pair_t* pair)
rbt->style->freeer[MOO_RBT_KEY] (rbt, KPTR(pair), KLEN(pair)); rbt->style->freeer[MOO_RBT_KEY] (rbt, KPTR(pair), KLEN(pair));
if (rbt->style->freeer[MOO_RBT_VAL] != MOO_NULL) if (rbt->style->freeer[MOO_RBT_VAL] != MOO_NULL)
rbt->style->freeer[MOO_RBT_VAL] (rbt, VPTR(pair), VLEN(pair)); rbt->style->freeer[MOO_RBT_VAL] (rbt, VPTR(pair), VLEN(pair));
MOO_MMGR_FREE (rbt->moo->mmgr, pair); moo_freemem (rbt->moo, pair);
} }
static moo_rbt_style_t style[] = static moo_rbt_style_t style[] =
@ -195,12 +195,12 @@ moo_rbt_t* moo_rbt_open (moo_t* moo, moo_oow_t xtnsize, int kscale, int vscale)
{ {
moo_rbt_t* rbt; moo_rbt_t* rbt;
rbt = (moo_rbt_t*) MOO_MMGR_ALLOC (moo->mmgr, MOO_SIZEOF(moo_rbt_t) + xtnsize); rbt = (moo_rbt_t*)moo_allocmem(moo, MOO_SIZEOF(moo_rbt_t) + xtnsize);
if (rbt == MOO_NULL) return MOO_NULL; if (!rbt) return MOO_NULL;
if (moo_rbt_init(rbt, moo, kscale, vscale) <= -1) if (moo_rbt_init(rbt, moo, kscale, vscale) <= -1)
{ {
MOO_MMGR_FREE (moo->mmgr, rbt); moo_freemem (moo, rbt);
return MOO_NULL; return MOO_NULL;
} }
@ -211,7 +211,7 @@ moo_rbt_t* moo_rbt_open (moo_t* moo, moo_oow_t xtnsize, int kscale, int vscale)
void moo_rbt_close (moo_rbt_t* rbt) void moo_rbt_close (moo_rbt_t* rbt)
{ {
moo_rbt_fini (rbt); moo_rbt_fini (rbt);
MOO_MMGR_FREE (rbt->moo->mmgr, rbt); moo_freemem (rbt->moo, rbt);
} }
int moo_rbt_init (moo_rbt_t* rbt, moo_t* moo, int kscale, int vscale) int moo_rbt_init (moo_rbt_t* rbt, moo_t* moo, int kscale, int vscale)

View File

@ -379,7 +379,7 @@ struct xtn_t
} ev; } ev;
}; };
#define GET_XTN(moo) ((xtn_t*)moo_getxtn(moo)) #define GET_XTN(moo) ((xtn_t*)((moo_uint8_t*)moo_getxtn(moo) - MOO_SIZEOF(xtn_t)))
static moo_t* g_moo = MOO_NULL; static moo_t* g_moo = MOO_NULL;
@ -3649,6 +3649,9 @@ static void fini_moo (moo_t* moo)
moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize, ((cfg && cfg->cmgr)? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo); moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize, ((cfg && cfg->cmgr)? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo);
if (!moo) return MOO_NULL; if (!moo) return MOO_NULL;
/* adjust the object size by the sizeof xtn_t so that qse_getxtn() returns the right pointer. */
moo->_instsize += MOO_SIZEOF(xtn_t);
xtn = GET_XTN(moo); xtn = GET_XTN(moo);
if (cfg) xtn->input_cmgr = cfg->input_cmgr; if (cfg) xtn->input_cmgr = cfg->input_cmgr;
if (!xtn->input_cmgr) xtn->input_cmgr = moo_getcmgr(moo); if (!xtn->input_cmgr) xtn->input_cmgr = moo_getcmgr(moo);
@ -3691,11 +3694,6 @@ static void fini_moo (moo_t* moo)
return moo; return moo;
} }
void* moo_getxtnstd (moo_t* moo)
{
return (void*)((moo_uint8_t*)GET_XTN(moo) + MOO_SIZEOF(xtn_t));
}
void moo_abortstd (moo_t* moo) void moo_abortstd (moo_t* moo)
{ {
#if defined(USE_THREAD) #if defined(USE_THREAD)

View File

@ -879,7 +879,7 @@ int moo_convbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_
{ {
/* length bound */ /* length bound */
int n; int n;
n = moo_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); n = moo_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, moo_getcmgr(moo), 0);
/* -1: illegal character, -2: buffer too small, -3: incomplete sequence */ /* -1: illegal character, -2: buffer too small, -3: incomplete sequence */
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR); if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
return n; return n;
@ -889,7 +889,7 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_
{ {
/* length bound */ /* length bound */
int n; int n;
n = moo_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); n = moo_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, moo_getcmgr(moo));
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR); if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
return n; return n;
} }
@ -898,7 +898,7 @@ int moo_convbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_u
{ {
/* null-terminated. */ /* null-terminated. */
int n; int n;
n = moo_conv_bcstr_to_ucstr_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); n = moo_conv_bcstr_to_ucstr_with_cmgr(bcs, bcslen, ucs, ucslen, moo_getcmgr(moo), 0);
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR); if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
return n; return n;
} }
@ -907,7 +907,7 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
{ {
/* null-terminated */ /* null-terminated */
int n; int n;
n = moo_conv_ucstr_to_bcstr_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); n = moo_conv_ucstr_to_bcstr_with_cmgr(ucs, ucslen, bcs, bcslen, moo_getcmgr(moo));
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR); if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
return n; return n;
} }