| 44 | /* This function allocate the buffers. It is necessary to call |
| 45 | re_string_reconstruct before using the object. */ |
| 46 | |
| 47 | static reg_errcode_t |
| 48 | internal_function |
| 49 | re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len, |
| 50 | RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) |
| 51 | { |
| 52 | reg_errcode_t ret; |
| 53 | int init_buf_len; |
| 54 | |
| 55 | /* Ensure at least one character fits into the buffers. */ |
| 56 | if (init_len < dfa->mb_cur_max) |
| 57 | init_len = dfa->mb_cur_max; |
| 58 | init_buf_len = (len + 1 < init_len) ? len + 1: init_len; |
| 59 | re_string_construct_common (str, len, pstr, trans, icase, dfa); |
| 60 | |
| 61 | ret = re_string_realloc_buffers (pstr, init_buf_len); |
| 62 | if (BE (ret != REG_NOERROR, 0)) |
| 63 | return ret; |
| 64 | |
| 65 | pstr->word_char = dfa->word_char; |
| 66 | pstr->word_ops_used = dfa->word_ops_used; |
| 67 | pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; |
| 68 | pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; |
| 69 | pstr->valid_raw_len = pstr->valid_len; |
| 70 | return REG_NOERROR; |
| 71 | } |
| 72 | |
| 73 | /* This function allocate the buffers, and initialize them. */ |
no test coverage detected