File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -297,8 +297,12 @@ conv_mem_reserve(ipx_nf9_conv_t *conv, size_t size)
297297 return IPX_OK ;
298298 }
299299
300- // Reallocate // TODO: improve size - multiples of 1024? 1024, 2048, 4096, ...
301- size_t new_alloc = conv -> data .ipx_size_used + size ; // TODO: during TEST allocate only to required size and use valgrind
300+ // Reallocate - use multiples of 1024 to avoid too many reallocations
301+ size_t new_alloc = conv -> data .ipx_size_used + size ;
302+ new_alloc /= 1024U ;
303+ new_alloc += 1U ;
304+ new_alloc *= 1024U ;
305+ // TODO: during TEST allocate only to required size and use valgrind
302306 uint8_t * new_msg = realloc (conv -> data .ipx_msg , new_alloc * sizeof (uint8_t ));
303307 if (!new_msg ) {
304308 return IPX_ERR_NOMEM ;
You can’t perform that action at this time.
0 commit comments