>Perhaps the best that you can do is modify the custom allocator
>using something like:
>-----
>  #include <valgrind.h>
>
>       if (RUNNING_ON_VALGRIND)
>               *p = 0;
>       else if (*p)
>               *p = 0;

I wonder if the above "if-s" are really needed.
I think that on many modern cpu (with pipe lines etc),
it might be faster to just do
    *p = 0;
    return p;

rather than to do one or more "if-s" to avoid an assignment.

I also believe that RUNNING_ON_VALGRIND has a certain cost even when
not running under valgrind.
So, in many case, the above code will incur the cost of two "if-s".

And so, always do:
    *p = 0;
    return p;
will always be faster (with or without valgrind),
and will not cause any strange errors with valgrind.

Would be worth verifying this (maybe with callgrind/cachegrind :).

Philippe

____
 
This message and any files transmitted with it are legally privileged and 
intended for the sole use of the individual(s) or entity to whom they are 
addressed. If you are not the intended recipient, please notify the sender by 
reply and delete the message and any attachments from your system. Any 
unauthorised use or disclosure of the content of this message is strictly 
prohibited and may be unlawful.
 
Nothing in this e-mail message amounts to a contractual or legal commitment on 
the part of EUROCONTROL, unless it is confirmed by appropriately signed hard 
copy.
 
Any views expressed in this message are those of the sender.

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to