~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/include/pgscript/utilities/pgsAlloc.h

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// pgScript - PostgreSQL Tools
 
4
// RCS-ID:      $Id: pgsAlloc.h 7758 2009-03-26 20:49:59Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
 
7
//
 
8
//////////////////////////////////////////////////////////////////////////
 
9
 
 
10
 
 
11
#ifndef PGSALLOC_H
 
12
#define PGSALLOC_H
 
13
 
 
14
#if defined(PGSDEBUG)
 
15
 
 
16
#include <cstdlib> // malloc and free
 
17
#include <new> // std::bad_alloc
 
18
#include <wx/hashmap.h>
 
19
 
 
20
struct pgsMallocInfo
 
21
{
 
22
        const void * ptr;
 
23
        size_t size;
 
24
        wxString filename;
 
25
        size_t line_nb;
 
26
};
 
27
 
 
28
WX_DECLARE_VOIDPTR_HASH_MAP(pgsMallocInfo, pgsMallocInfoMap);
 
29
 
 
30
class pgsAlloc
 
31
{
 
32
 
 
33
protected:
 
34
        
 
35
        pgsAlloc();
 
36
 
 
37
        pgsMallocInfoMap m_malloc_info;
 
38
 
 
39
private:
 
40
 
 
41
        void add_malloc(const pgsMallocInfo & malloc_info);
 
42
        
 
43
        void rm_malloc(const void * ptr);
 
44
                        
 
45
public:
 
46
        
 
47
        void * pmalloc(size_t size, const char * filename, size_t line_nb);
 
48
        
 
49
        void dump();
 
50
        
 
51
        void pfree(void * ptr);
 
52
        
 
53
        static pgsAlloc & instance();
 
54
        
 
55
};
 
56
 
 
57
void * operator new(size_t size) throw (std::bad_alloc);
 
58
void * operator new[](size_t size) throw (std::bad_alloc);
 
59
void * operator new(size_t size, const char * filename, size_t line_nb)
 
60
        throw (std::bad_alloc);
 
61
void * operator new[](size_t size, const char * filename, size_t line_nb)
 
62
        throw (std::bad_alloc);
 
63
void operator delete(void * ptr) throw ();
 
64
void operator delete[](void * ptr) throw ();
 
65
 
 
66
#define pnew new(__FILE__, __LINE__)
 
67
 
 
68
#else
 
69
 
 
70
#define pnew new
 
71
 
 
72
#endif // PGSDEBUG
 
73
 
 
74
#define pdelete(x)  if ((x) != 0) { delete   x; x = 0; }
 
75
#define pdeletea(x) if ((x) != 0) { delete[] x; x = 0; }
 
76
 
 
77
#endif /*PGSALLOC_H_*/