Re: Securing a C++ class



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.)
.



Relevant Pages

  • Re: Fate of lambda, Functional Programming in Python...
    ... Simple map and filter implementations ... if init is None: ... Macros for an infix language are not impossible, ...
    (comp.lang.python)
  • Re: FSet/CL 1.0 released!
    ... The former example shows that 'map' is a macro with its own evaluation ... both macros with syntax, but the syntax of `map' is more complex (and ... other constructor macros too, ...
    (comp.lang.lisp)
  • Re: Securing a C++ class
    ... macros for all calloc/malloc/free/realloc and the developer could map ... Thanks for the input, Tom. ... template parameter and give a default value for that parameter (so users ...
    (sci.crypt)
  • Re: Securing a C++ class
    ... macros for all calloc/malloc/free/realloc and the developer could map ... Thanks for the input, Tom. ... template parameter and give a default value for that parameter (so users ...
    (sci.crypt)
  • Help with 2-level macro expansion
    ... We have bunch of message levels and depending on whether that level is ... We want to provide a wrapper API on top of this to print various kinds ... we might map MSG_FUNCTION_ENTRY to MSG_MED ... I wrote following macros to get this functionality. ...
    (comp.lang.c)

Quantcast