/** * Game Develop * Editor * * Par Florian "4ian" Rival * */ /** * * * Suivi des allocations avec new/delete */ #define DWORD unsigned long #include #include #include #include #include /* Désactivé car incompatible avec GCC 4.1 */ /* typedef struct { DWORD address; DWORD size; char file[128]; DWORD line; } ALLOC_INFO; typedef std::list AllocList; AllocList *allocList; void AddTrack(DWORD addr, DWORD asize, const char *fname, DWORD lnum) { ALLOC_INFO *info; if(!allocList) { allocList = new(AllocList); } info = new(ALLOC_INFO); info->address = addr; strncpy(info->file, fname, 128); info->line = lnum; info->size = asize; allocList->insert(allocList->begin(), info); } void RemoveTrack(DWORD addr) { AllocList::iterator i; if(!allocList) return; for(i = allocList->begin(); i != allocList->end(); i++) { if((*i)->address == addr) { delete (*i); allocList->erase(i); break; } } } void DumpUnfreed() { AllocList::iterator i; DWORD totalSize = 0; char buf[1024]; if(!allocList) return; std::cout << "\nRapport de Memory Tracker----------------------------------\n\n"; //std::cout<begin(); i != allocList->end(); i++) { sprintf(buf, "%s\nLigne %d Adresse %d, %d bytes non lib\202r\202s\n", (*i)->file, (*i)->line, (*i)->address, (*i)->size); std::cout<size; } sprintf(buf, "-----------------------------------------------------------\n"); std::cout<