On 7/28/22 9:25 PM, Ruediger Pluem wrote:
>
>
> On 7/15/22 12:36 PM, yla...@apache.org wrote:
>> Author: ylavic
>> Date: Fri Jul 15 10:36:24 2022
>> New Revision: 1902731
>>
>> URL: http://svn.apache.org/viewvc?rev=1902731&view=rev
>>
>> - state->buf_used += APR_ALIGN_DEFAULT(size);
>> +#if APREG_USE_THREAD_LOCAL
>> + if (state->thd) {
>> + struct match_thread_state *ts = thread_state;
>> + void *p;
>> +
>> + if (!ts) {
>> + apr_pool_t *tp = apr_thread_pool_get(state->thd);
>> + ts = apr_pcalloc(tp, sizeof(*ts));
>> + apr_pool_create(&ts->pool, tp);
>> + thread_state = state->ts = ts;
>> + }
>> + else if (!state->ts) {
>> + ts->heap_used = 0;
>> + state->ts = ts;
>> + }
>>
>> + avail = ts->heap_size - ts->heap_used;
>> + if (avail >= size) {
>> + size = APR_ALIGN_DEFAULT(size);
>> + if (size > avail) {
>> + size = avail;
>> + }
>> + p = ts->heap + ts->heap_used;
>> + }
>> + else {
>> + ts->heap_size *= 2;
>> + size = APR_ALIGN_DEFAULT(size);
>> + if (ts->heap_size < size) {
>> + ts->heap_size = size;
>> + }
>> + if (ts->heap_size < AP_PCRE_STACKBUF_SIZE * 2) {
>> + ts->heap_size = AP_PCRE_STACKBUF_SIZE * 2;
>> + }
>> + ts->heap = apr_palloc(ts->pool, ts->heap_size);
>> + ts->heap_used = 0;
>> + p = ts->heap;
>
> I think that apr_palloc should be efficient enough for allocating memory
> quickly and
> that we don't need to reserve bigger memory chunks manage them here locally
> that looks
> like what apr_palloc already does.
Already done by r1902858 :-)
Regards
RĂ¼diger