On Wed, 22 Sep 1999 07:44:51 +0200 (METDST), Asger K. Alstrup Nielsen
wrote:
>> Try to use small and better maintainable "static inline" functions
>> allocating memory objects only on their stack frame, i.e. using
>> variables local to them, consistently avoiding 'new'/'delete'. Thus
>> memory remains confined within block nesting and exists only during
>> block life time. This should reduce most problems described at the
>> beginning.
>>
>> Use preferably "alloc"-style garbage collection avoiding explicit
>> memory deallocation ("delete"/"free()") if this is possible.
>>
>> I've no proposal for global linked list-type objects that need dynamic
>> memory :(.
>
>I do: The STL.
>
>The STL encapsulates dynamic containers in the assignable wrapping.
>Thereby, you can have for instance linked lists without the hassle
>of dynamic memory management.
>
>The key to solve this memory problem is exactly the assignable concept.
>If all our types are assignable, we will have no memory problems.
>
>So, read up on the assignable concept, and heed that in the implementation
>of our classes, and we should be much better off. This trend was started
>a long time ago, when LString was introduced instead of the hard-coded
>C char arrays.
>It continued in the 1.1.x branch, when we decided to use the STL, and
>some areas were much cleaned up by this. Now, these good parst should
>be backported to the new 1.1.x branch (Lgb, when is that up?), and
>we should continue to get rid of most new/deletes.
>
>For instance, at the TILDEM, we implemented a new menu-abstraction
>which completely encapsulated all dynamic memory management behind
>a big wall, and the outside world did not have to worry about it.
For wizards:
Does the *internal* implementation of those 'killer templates
:)' or abstraction schemes eventually employ malloc()?
Moreover I'd like to repeat my older suggestion: Please take your nice
summaries (like this one!) out of this mass-grave of letters (aka mail
archive) and resurrect them on-line. Or you could hack together a
bsd-like TOUR text, introducing some concepts employed in the sources.
(Don't try to make the texts perfect; it's impossible anyway ;)
And I'd suggest adding to the coding rule document a reminder that you
can use in many cases (in figinset.C at least nearly everywhere) the
most obvious solution so as to avoid malloc() hassle: Small static
inline fns and local variables.
Greets,
Arnd