added moo_duputobcharswithheadroom(), moo_dupbtoucharswithheadroom()

added moo_inttoooi() and made public moo_inttooow()
enhanced the ffi module a bit more
This commit is contained in:
hyunghwan.chung
2017-01-15 17:53:37 +00:00
parent 79198df35b
commit 70f9976af3
12 changed files with 299 additions and 110 deletions

View File

@ -670,7 +670,7 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
/* ----------------------------------------------------------------------- */
moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
MOO_INLINE moo_uch_t* moo_dupbtoucharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
{
moo_oow_t inlen, outlen;
moo_uch_t* ptr;
@ -682,10 +682,12 @@ moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen,
return MOO_NULL;
}
ptr = moo_allocmem (moo, (outlen + 1) * MOO_SIZEOF(moo_uch_t));
ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_uch_t)));
if (!ptr) return MOO_NULL;
inlen = bcslen;
ptr = (moo_uch_t*)((moo_oob_t*)ptr + headroom_bytes);
moo_convbtouchars (moo, bcs, &inlen, ptr, &outlen);
/* moo_convbtouchars() doesn't null-terminate the target.
@ -696,7 +698,12 @@ moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen,
return ptr;
}
moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
moo_uch_t* moo_dupbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen, moo_oow_t* ucslen)
{
return moo_dupbtoucharswithheadroom (moo, 0, bcs, bcslen, ucslen);
}
MOO_INLINE moo_bch_t* moo_duputobcharswithheadroom (moo_t* moo, moo_oow_t headroom_bytes, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
{
moo_oow_t inlen, outlen;
moo_bch_t* ptr;
@ -708,10 +715,11 @@ moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen,
return MOO_NULL;
}
ptr = moo_allocmem (moo, (outlen + 1) * MOO_SIZEOF(moo_bch_t));
ptr = moo_allocmem (moo, headroom_bytes + ((outlen + 1) * MOO_SIZEOF(moo_bch_t)));
if (!ptr) return MOO_NULL;
inlen = ucslen;
ptr = (moo_bch_t*)((moo_oob_t*)ptr + headroom_bytes);
moo_convutobchars (moo, ucs, &inlen, ptr, &outlen);
ptr[outlen] = '\0';
@ -719,6 +727,11 @@ moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen,
return ptr;
}
moo_bch_t* moo_duputobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen, moo_oow_t* bcslen)
{
return moo_duputobcharswithheadroom (moo, 0, ucs, ucslen, bcslen);
}
moo_uch_t* moo_dupbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* ucslen)
{
moo_oow_t inlen, outlen;
@ -759,7 +772,6 @@ moo_bch_t* moo_duputobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* bcslen)
return ptr;
}
/* ----------------------------------------------------------------------- */
moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen)