forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 9:56 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Combining the *_destroy() and *_clear() routines.
PostPosted: Tue Mar 05, 2019 10:48 pm 
Offline

Joined: Mon Nov 20, 2017 11:14 pm
Posts: 21
In my copy of ALGLIB, I combined the T_destroy() and T_clear() routines, for all the object types T, into T_free(void *ptr, ae_bool make_automate) with T_clear(...) = T_free(..., ae_true) and T_destroy(...) = T_free(..., ae_false). The name of extra parameter is justified by the fact that it is used in the same way as it is for the T_init(...) and T_init_copy(...) routines: ae_false for global objects and ae_true for local objects that go on the frame.

In the process of doing this, I ran into (but successfully resolved) a few problems that you probably encountered. You may be able to use this in your version.
(1) The destroy() functions are declared as members in ae_smart_ptr and ae_shared_pool. These I change to void (*destroy)(void *ptr, ae_bool make_automatic).
(2) It is also declared as a member in void (*deallocator)(void *ptr) in ae_dyn_block. This is kept the same.
(3) Instances of T_{clear/destroy}(...) are replaced by T_free(..., make_automatic) where the definitions of T_clear() and T_destroy() are merged into the definition of T_free().
(4) Instances of T_clear(...) are replaced by T_free(..., ae_true); and T_destroy(...) by T_free(..., ae_false), wherever they occur.
(5) Instances of calls to the destroy(...) field are replaced by calls to free(..., ae_false)
(6) ae_db_free(), ae_free_lock() do *not* get the extra parameter make_automatic, but ae_{vector,matrix,smart_ptr}_{destroy,clear}() do and are combined into ae_{vector,matrix,smart_ptr}_free().
(7) A dummy routine for ae_smart_ptr_destroy(...) = ae_smart_ptr_free(..., ae_false) is declared for use as the deallocator field of ae_dyn_block ... which happens once in ae_shared_pool_init().
(8) The routine ae_shared_pool_internalclear() also gets the make_automatic parameter; it is passed on as the extra parameter when the member field dst->destroy(...) is replaced by dst->free(..., make_automatic).
(9) It is invoked as ae_shared_pool_internalclear(..., make_automatic) in the definition of ae_shared_pool_free(..., make_automatic) (which replaced the definitions of ae_shared_pool_{clear/destroy}()), but as ae_shared_pool_internalclear(..., ae_false) in the definitions of ae_shared_pool_set_seed() and ae_shared_pool_reset().


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group