1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include "DwarfManager.h" 7 8#include <new> 9 10#include <AutoDeleter.h> 11#include <AutoLocker.h> 12 13#include "DwarfFile.h" 14 15 16DwarfManager::DwarfManager() 17 : 18 fLock("dwarf manager") 19{ 20} 21 22 23DwarfManager::~DwarfManager() 24{ 25} 26 27 28status_t 29DwarfManager::Init() 30{ 31 return fLock.InitCheck(); 32} 33 34 35status_t 36DwarfManager::LoadFile(const char* fileName, DwarfFile*& _file) 37{ 38 AutoLocker<DwarfManager> locker(this); 39 40 DwarfFile* file = new(std::nothrow) DwarfFile; 41 if (file == NULL) 42 return B_NO_MEMORY; 43 44 BReference<DwarfFile> fileReference(file, true); 45 status_t error = file->Load(fileName); 46 if (error != B_OK) { 47 return error; 48 } 49 50 fFiles.Add(file); 51 fileReference.Detach(); 52 // we keep the initial reference for ourselves 53 54 file->AcquireReference(); 55 _file = file; 56 return B_OK; 57} 58 59 60status_t 61DwarfManager::FinishLoading() 62{ 63 AutoLocker<DwarfManager> locker(this); 64 65 for (FileList::Iterator it = fFiles.GetIterator(); 66 DwarfFile* file = it.Next();) { 67 status_t error = file->FinishLoading(); 68 if (error != B_OK) 69 return error; 70 } 71 72 return B_OK; 73} 74