[aspectc-user] pointcut on new and delete operator

Terry zhenrong.yang at gmail.com
Fri May 19 01:58:17 CEST 2006


Hi,

I am experimenting ac++ (version 1.0pre3) with ACDT in eclipse. I declared
my aspect as following, however, the advice on the pointcut doesn't seem to
work at all. Any clue to solve the problem is appreciated.

** aspect:
#include <iostream>
using namespace std;
aspect myAspect {
    pointcut locked () = execution ("% ...::operator new(...)") ||
                         execution ("% ...::operator new[](...)") ||
                         execution ("% ...::operator delete(...)") ||
                         execution ("% ...::operator delete[](...)");

    advice locked () : after ()
    {
        cout << "new or delete operator executed" << endl;
    }
};

** c++ code
#include <iostream>
#include <stdlib.h>
#include <cmath>

using namespace std;

class A {};

int main () {

    int* pInt = new int;
    A* pA = new A;

    delete pInt;
    pInt = 0;
    delete pA;
    pA = 0;

    return 0;
}

Thanks!

Terry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20060518/752c6224/attachment.html>


More information about the aspectc-user mailing list