Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Name : loadeddlls.cpp
15 // Part of : libdl library
16 // Implements and maintains the list of opened dll.
21 #include "loadeddlls.h"
23 //-----------------------------------------------------------------------------
24 //Function Name : CLoadedDlls::CLoadedDlls()
25 //Description : Constructor
26 //-----------------------------------------------------------------------------
27 CLoadedDlls::CLoadedDlls()
29 const TInt error = CreateLock();
30 //if error creating lock, panic.
31 if ( KErrNone != error )
33 User::Panic(_L(""), error);
37 //-----------------------------------------------------------------------------
38 //Function Name : CLoadedDlls::~CLoadedDlls()
39 //Description : Destructor
40 //-----------------------------------------------------------------------------
41 CLoadedDlls::~CLoadedDlls()
47 //-----------------------------------------------------------------------------
48 //Function Name : TInt CLoadedDlls::Add(const TDllEntry& aDllEntry)
49 //Description : To add the dll to the list.
50 //Return Value : KErrNone if added successfully else system wide error
51 //-----------------------------------------------------------------------------
52 TInt CLoadedDlls::Add(const TDllEntry& aDllEntry)
54 return iHandleList.Append(aDllEntry);
57 //-----------------------------------------------------------------------------
58 //Function Name : void CLoadedDlls::Remove(const TInt aIndex)
59 //Description : To remove the dll from the list.
60 //-----------------------------------------------------------------------------
61 void CLoadedDlls::Remove(const TInt aIndex)
63 iHandleList.Remove(aIndex);
64 iHandleList.GranularCompress();
67 //-----------------------------------------------------------------------------
68 //Function Name : TDllEntry& CLoadedDlls::At(const TInt aIndex)
69 //Description : Get DllEntry& at particular index. This function assumes that
71 //Return Value : TDllEntry& DllEntry corresponding to aIndex
72 //-----------------------------------------------------------------------------
73 TDllEntry& CLoadedDlls::At(const TInt aIndex)
75 return iHandleList[aIndex];
78 //-----------------------------------------------------------------------------
79 //Function Name : TInt CLoadedDlls::Find(const void* aHandle) const
80 //Description : Finds if dll with this handle exist or not
81 //Return Value : Index in list if found else KErrNotFound
82 //-----------------------------------------------------------------------------
83 TInt CLoadedDlls::Find(const void* aHandle) const
85 TDllEntry tempDllEntry((TInt) aHandle);
86 return iHandleList.Find(tempDllEntry, TIdentityRelation<TDllEntry>(TDllEntry::CompareByHandle));
89 //-----------------------------------------------------------------------------
90 //Function Name : TInt CLoadedDlls::Find(const RLibrary& aLibrary) const
91 //Description : Finds if dll with this library i.e. same path exist or not
92 //Return Value : Index in list if found else KErrNotFound
93 //-----------------------------------------------------------------------------
94 TInt CLoadedDlls::Find(const RLibrary& aLibrary) const
96 TDllEntry tempDllEntry(aLibrary);
97 return iHandleList.Find(tempDllEntry,TIdentityRelation<TDllEntry>(TDllEntry::CompareByPath));
100 //-----------------------------------------------------------------------------
101 //Function Name : TBool TDllEntry::CompareByHandle(const TDllEntry& aEntry)
102 //Description : Comparator function, compares iLibrary.Handle() of two
104 //Return Value : ETrue if Handle of both TDllEntry's RLibrary's matches
106 //-----------------------------------------------------------------------------
107 TBool TDllEntry::CompareByHandle(const TDllEntry& aEntry1, const TDllEntry& aEntry2)
109 if (aEntry1.iLibrary.Handle() == aEntry2.iLibrary.Handle())
116 //-----------------------------------------------------------------------------
117 //Function Name : TBool TDllEntry::CompareByPath(const TDllEntry& aEntry)
118 //Description : Comparator function, compares path corresponding to two
120 //Return Value : ETrue if file name of both TDllEntry's RLibrary's matches
122 //-----------------------------------------------------------------------------
123 TBool TDllEntry::CompareByPath(const TDllEntry& aEntry1, const TDllEntry& aEntry2)
125 if (aEntry1.iLibrary.FileName().Compare(aEntry2.iLibrary.FileName()))
132 //-----------------------------------------------------------------------------
133 //Function Name : TDllEntry::TDllEntry(const RLibrary aLibrary, const TInt aFlag)
134 //Description : constructor. to initialise library by RLibrary object
135 //-----------------------------------------------------------------------------
136 TDllEntry::TDllEntry(const RLibrary& aLibrary, const TInt aFlag) : iLibrary(aLibrary), iFlags(aFlag), iRefCount(1)