Re: Securing a C++ class
- From: Bruce Stephens <bruce+usenet@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 23 Jul 2009 18:32:05 +0100
Tom St Denis <tom@xxxxxxx> writes:
[...]
In LibTomCrypt [C not C++ but same thought process works here] I used
macros for all calloc/malloc/free/realloc and the developer could map
them to anything they wanted at build time.
In more recent work I use the same idea to map them to debug versions
which trap stack traces of when/where operations occur, then they can
report memory leaks down to exactly where they occurred.
macros would also work in C++ (obviously).
An alternative would be to template the classes with an Allocator
template parameter and give a default value for that parameter (so users
who don't care don't need to provide it), much as is done with the
containers in the Standard library. (I guess that's more what a C++ user
might expect, though for this purpose personally I wouldn't mind the
macro solution either.)
.
- Follow-Ups:
- Re: Securing a C++ class
- From: Jonathan Lee
- Re: Securing a C++ class
- References:
- Securing a C++ class
- From: Jonathan Lee
- Re: Securing a C++ class
- From: Tom St Denis
- Securing a C++ class
- Prev by Date: Re: Securing a C++ class
- Next by Date: Re: Teach myself C++.
- Previous by thread: Re: Securing a C++ class
- Next by thread: Re: Securing a C++ class
- Index(es):
Relevant Pages
|