Custom operator new/delete

I'm using a class from which a lot of single instances are allocated and deallocated at the same time. To make allocation more efficient I thought I would give a shot to boost's pool allocator library.
Below is how I rewrote the operator new and delete for my class. Unfortunately this might made a memory leak, my question is:
Is this a correct implementation and so I have to search for the memory leak source somewhere else?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <new>
#include <boost/pool/singleton_pool.hpp>

class particle {
public:
    static void *operator new(size_t size);
    static void operator delete(void *p, size_t size);
//...
};

void *particle::operator new(size_t size) {
    if (size != sizeof(particle))
        return ::operator new(size);

    typedef boost::singleton_pool<boost::pool_allocator_tag, sizeof(particle)> pool_t;

    while(true) {
        void *p = pool_t::malloc();
        if (p) {
            return p;
        }
        std::new_handler global_handler = std::set_new_handler(0);
        std::set_new_handler(global_handler);
        if (global_handler) 
            (*global_handler)();
        else
            throw std::bad_alloc();

    }

}

void particle::operator delete(void *p, size_t size) {
    if (p) {
        if (size != sizeof(particle))
            ::operator delete(p);
        else {
            typedef boost::singleton_pool<boost::pool_allocator_tag, sizeof(particle)> pool_t;
            pool_t::free(p);
        }
    }
}
Topic archived. No new replies allowed.