Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1.2 and tip

stable shellext: use std::vector in CSimpleUnknown

Changeset c90f86734702

Parent ddf3dce6c1c8

by Adrian Buehlmann

Changes to 2 files · Browse files at c90f86734702 Showing diff from parent ddf3dce6c1c8 Diff from another changeset...

 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
 
45
46
47
 
49
50
51
52
 
53
54
 
55
56
57
 
 
58
59
60
 
19
20
21
 
22
23
24
25
26
27
 
 
 
 
 
 
 
28
29
30
31
 
 
 
 
 
32
33
34
35
36
 
38
39
40
 
41
42
 
43
44
 
 
45
46
47
48
49
@@ -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
17
18
 
 
19
20
21
 
42
43
44
 
45
46
47
48
49
 
 
 
 
50
51
52
 
16
17
18
19
20
21
22
23
 
44
45
46
47
48
49
 
50
 
51
52
53
54
55
56
57
@@ -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: