From 83e45de23e565138b8fde06fb11cfedc973b7246 Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Thu, 18 Apr 2013 18:33:03 -0500 Subject: [PATCH] Allow packm_init() to reacquire a too-small mem_t. Details: - Changed bli_packm_init() to react differently to a situation where a pack obj_t has an already-allocated mem_t entry that has a buffer that is smaller than what will be needed to hold the block/panel that now needs to be packed. Previously, this situation was treated with an abort() since I assumed something was horribly wrong. I have changed the code so that it now reacts by releasing the previous mem_t and re-acquires a new mem_t with the new information. (This change was done at the request of Bryan Marker to facilitate code generation via DxT.) --- frame/1m/packm/bli_packm_init.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frame/1m/packm/bli_packm_init.c b/frame/1m/packm/bli_packm_init.c index c8c0cacb1..e942a6b0d 100644 --- a/frame/1m/packm/bli_packm_init.c +++ b/frame/1m/packm/bli_packm_init.c @@ -384,11 +384,17 @@ void bli_packm_init_pack( bool_t densify, else { // If the mem_t object is currently allocated and smaller than is - // needed, then something is very wrong, since the cache blocksizes - // that drive the level-3 blocked algorithms are the same ones that - // determine the sizes of the blocks within our memory allocator's - // memory pools. This branch should never be executed. - if ( bli_mem_size( mem_p ) < size_p ) bli_abort(); + // needed, then it must have been allocated for a different type + // of object (a different pack_buf_type value), so we must first + // release it and then re-acquire it using the new size and new + // pack_buf_type value. + if ( bli_mem_size( mem_p ) < size_p ) + { + bli_mem_release( mem_p ); + bli_mem_acquire_m( size_p, + pack_buf_type, + mem_p ); + } } // Grab the buffer address from the mem_t object and copy it to the