/* ASCII lowercase function (string version); See string.h */ ib_status_t ib_strlower(ib_strop_t op, ib_mpool_t *mp, char *str_in, char **str_out, ib_flags_t *result) { IB_FTRACE_INIT(); size_t len; ib_status_t rc = IB_OK; char *out = NULL; assert(mp != NULL); assert(str_in != NULL); assert(str_out != NULL); assert(result != NULL); len = strlen(str_in); switch(op) { case IB_STROP_INPLACE: out = str_in; rc = inplace(IB_STRFLAG_ALIAS, (uint8_t*)str_in, len, result); break; case IB_STROP_COPY: out = ib_mpool_strdup(mp, str_in); if (out == NULL) { IB_FTRACE_RET_STATUS(IB_EALLOC); } rc = inplace(IB_STRFLAG_NEWBUF, (uint8_t*)out, len, result); break; case IB_STROP_COW: { #if ((__GNUC__==4) && (__GNUC_MINOR__<3)) uint8_t *uint8ptr; rc = copy_on_write(mp, (uint8_t *)str_in, len+1, &uint8ptr, &len, result); out = (char *)uint8ptr; #else rc = copy_on_write(mp, (uint8_t *)str_in, len+1, (uint8_t **)&out, &len, result); #endif break; } default: IB_FTRACE_RET_STATUS(IB_EINVAL); } if (rc == IB_OK) { if (ib_flags_all(*result, IB_STRFLAG_MODIFIED)) { *(out+len) = '\0'; } *str_out = out; } IB_FTRACE_RET_STATUS(rc); }
/* Simple ASCII lowercase function (ex version); see string.h */ ib_status_t ib_strlower_ex(ib_strop_t op, ib_mpool_t *mp, uint8_t *data_in, size_t dlen_in, uint8_t **data_out, size_t *dlen_out, ib_flags_t *result) { IB_FTRACE_INIT(); ib_status_t rc = IB_OK; assert(mp != NULL); assert(data_in != NULL); assert(data_out != NULL); assert(dlen_out != NULL); assert(result != NULL); switch(op) { case IB_STROP_INPLACE: rc = inplace(IB_STRFLAG_ALIAS, data_in, dlen_in, result); *data_out = data_in; *dlen_out = dlen_in; break; case IB_STROP_COPY: *data_out = ib_mpool_alloc(mp, dlen_in); if (*data_out == NULL) { IB_FTRACE_RET_STATUS(IB_EALLOC); } *dlen_out = dlen_in; rc = inplace(IB_STRFLAG_NEWBUF, *data_out, dlen_in, result); break; case IB_STROP_COW: rc = copy_on_write(mp, data_in, dlen_in, data_out, dlen_out, result); break; default: IB_FTRACE_RET_STATUS(IB_EINVAL); } IB_FTRACE_RET_STATUS(rc); }
result_t<typename std::iterator_traits<RaIt>::value_type> apply_algorithm(RaIt p_beg, RaIt p_end, F f, char const* name) { using value_type = typename std::iterator_traits<RaIt>::value_type; std::vector<value_type> inplace(p_beg, p_end); auto start = std::chrono::high_resolution_clock::now(); f(inplace); auto end = std::chrono::high_resolution_clock::now(); auto duration = end - start; return {std::move(inplace), duration, name}; }
value_type operator() (value_unicode_string const& ustr) const { value_unicode_string inplace(ustr); return inplace.reverse(); }
void assign_bits(void const* b, nbits num_bits) { set_nums<std::numeric_limits<decltype(m_num_bytes)>::max()>(num_bits); if (inplace()) { std::memcpy(&m_data.internal, b, m_num_bytes); } else { m_data.external = static_cast<uint8_t const*>(b); } }
bool transform1Inplace(IMutableHypergraph<Arc>& h) { inplace(h, iso); return true; }