~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/utils/sdlcheckutils.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-10-07 10:26:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131007102614-tg2zjdz8vmtl6n7i
Tags: 1.3.9.29-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#define DEBUG_SURFACE_ALLOCATION 1
37
37
 
38
 
struct SurfaceObject
 
38
struct MemoryObject
39
39
{
40
 
    SurfaceObject(const std::string &name, const char *const file,
41
 
                  const unsigned int line) :
 
40
    MemoryObject(const std::string &name, const char *const file,
 
41
                 const unsigned int line) :
42
42
        mName(name),
43
43
        mAddFile(strprintf("%s:%u", file, line)),
44
44
        mRemoveFile(),
52
52
    int mCnt;
53
53
};
54
54
 
55
 
std::map<SDL_Surface*, SurfaceObject*> mSurfaces;
 
55
std::map<void*, MemoryObject*> mSurfaces;
56
56
 
57
57
static SDL_Surface *addSurface(const char *const name,
58
58
                               SDL_Surface *const surface,
63
63
    logger->log("add surface: %s %s:%u %p", name,
64
64
        file, line, static_cast<void*>(surface));
65
65
#endif
66
 
    std::map<SDL_Surface*, SurfaceObject*>::iterator
 
66
    std::map<void*, MemoryObject*>::iterator
67
67
        it = mSurfaces.find(surface);
68
68
    if (it != mSurfaces.end())
69
69
    {
70
 
        SurfaceObject *const obj = (*it).second;
 
70
        MemoryObject *const obj = (*it).second;
71
71
        if (obj)
72
72
        {   // found some time ago created surface
73
73
#ifdef DEBUG_SURFACE_ALLOCATION
80
80
    }
81
81
    else
82
82
    {   // creating surface object
83
 
        mSurfaces[surface] = new SurfaceObject(name, file, line);
 
83
        mSurfaces[surface] = new MemoryObject(name, file, line);
84
84
    }
85
85
    return surface;
86
86
}
93
93
#ifdef DEBUG_SURFACE_ALLOCATION
94
94
    logger->log("delete surface: %s %s:%u %p", name, file, line, surface);
95
95
#endif
96
 
    std::map<SDL_Surface*, SurfaceObject*>::iterator
 
96
    std::map<void*, MemoryObject*>::iterator
97
97
        it = mSurfaces.find(surface);
98
98
    if (it == mSurfaces.end())
99
99
    {
102
102
    }
103
103
    else
104
104
    {
105
 
        SurfaceObject *const obj = (*it).second;
 
105
        MemoryObject *const obj = (*it).second;
106
106
        if (obj)
107
107
        {
108
108
            const int cnt = obj->mCnt;