Changeset c90f86734702…
Parent ddf3dce6c1c8…
by
Changes to 2 files · Browse files at c90f86734702 Showing diff from parent ddf3dce6c1c8 Diff from another changeset...
@@ -19,29 +19,18 @@
CSimpleUnknown::CSimpleUnknown()
{
- entries_ = NULL;
cRef_ = 0;
AddInterface(IID_IUnknown, this);
}
CSimpleUnknown::~CSimpleUnknown()
{
- Entry* entry = entries_;
- while (entry != NULL)
- {
- Entry* nextentry = entry->next;
- delete entry;
- entry = nextentry;
- }
}
void CSimpleUnknown::AddInterface(REFIID riid, LPUNKNOWN punk)
{
- Entry* newentry = new Entry;
- newentry->iid = riid;
- newentry->punk = punk;
- newentry->next = entries_;
- entries_ = newentry;
+ Entry e(riid, punk);
+ entries_.push_back(e);
}
STDMETHODIMP CSimpleUnknown::QueryInterface(REFIID riid, LPVOID FAR* ppv)
@@ -49,12 +38,12 @@ if (ppv == NULL)
return E_POINTER;
- for (Entry* entry = entries_; entry != NULL; entry = entry->next)
+ for (EntriesT::const_iterator i = entries_.begin(); i != entries_.end(); ++i)
{
- if (entry->iid == riid)
+ if (i->iid == riid)
{
- entry->punk->AddRef();
- *ppv = entry->punk;
+ i->punk->AddRef();
+ *ppv = i->punk;
return S_OK;
}
}
|
@@ -16,6 +16,8 @@ #ifndef _SIMPLEUNKNOWN_H_
#define _SIMPLEUNKNOWN_H_
+#include <vector>
+
#define DECLARE_UNKNOWN() \
STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppv); \
STDMETHOD_(ULONG, AddRef)(); \
@@ -42,11 +44,14 @@{
struct Entry
{
+ Entry(IID iid, LPUNKNOWN punk): iid(iid), punk(punk) {}
IID iid;
LPUNKNOWN punk;
- Entry* next;
};
- Entry* entries_;
+
+ typedef std::vector<Entry> EntriesT;
+
+ EntriesT entries_;
UINT cRef_;
protected:
|
Loading...