ReactOS  0.4.14-dev-376-gaedba84
dsa.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/debug.h"
Include dependency graph for dsa.c:

Go to the source code of this file.

Classes

struct  _DSA
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dsa)
 
HDSA WINAPI DSA_Create (INT nSize, INT nGrow)
 
BOOL WINAPI DSA_Destroy (HDSA hdsa)
 
BOOL WINAPI DSA_GetItem (HDSA hdsa, INT nIndex, LPVOID pDest)
 
LPVOID WINAPI DSA_GetItemPtr (HDSA hdsa, INT nIndex)
 
BOOL WINAPI DSA_SetItem (HDSA hdsa, INT nIndex, LPVOID pSrc)
 
INT WINAPI DSA_InsertItem (HDSA hdsa, INT nIndex, LPVOID pSrc)
 
INT WINAPI DSA_DeleteItem (HDSA hdsa, INT nIndex)
 
BOOL WINAPI DSA_DeleteAllItems (HDSA hdsa)
 
VOID WINAPI DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
 
void WINAPI DSA_DestroyCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
 
HDSA WINAPI DSA_Clone (HDSA hdsa)
 
ULONGLONG WINAPI DSA_GetSize (HDSA hdsa)
 

Function Documentation

◆ DSA_Clone()

HDSA WINAPI DSA_Clone ( HDSA  hdsa)

Definition at line 452 of file dsa.c.

453 {
454  HDSA dest;
455  INT i;
456 
457  TRACE("(%p)\n", hdsa);
458 
459  if (!hdsa)
460  return NULL;
461 
462  dest = DSA_Create (hdsa->nItemSize, hdsa->nGrow);
463  if (!dest)
464  return NULL;
465 
466  for (i = 0; i < hdsa->nItemCount; i++) {
467  void *ptr = DSA_GetItemPtr (hdsa, i);
468  if (DSA_InsertItem (dest, DA_LAST, ptr) == -1) {
469  DSA_Destroy (dest);
470  return NULL;
471  }
472  }
473 
474  return dest;
475 }
INT nItemSize
Definition: dsa.c:49
BOOL WINAPI DSA_Destroy(HDSA hdsa)
Definition: dsa.c:103
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: dsa.c:44
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
HDSA WINAPI DSA_Create(INT nSize, INT nGrow)
Definition: dsa.c:71
#define TRACE(s)
Definition: solgame.cpp:4
INT nGrow
Definition: dsa.c:50
LPVOID WINAPI DSA_GetItemPtr(HDSA hdsa, INT nIndex)
Definition: dsa.c:162
#define DA_LAST
Definition: commctrl.h:4779
INT nItemCount
Definition: dsa.c:46
static char * dest
Definition: rtl.c:135
INT WINAPI DSA_InsertItem(HDSA hdsa, INT nIndex, LPVOID pSrc)
Definition: dsa.c:251

◆ DSA_Create()

HDSA WINAPI DSA_Create ( INT  nSize,
INT  nGrow 
)

Definition at line 71 of file dsa.c.

72 {
73  HDSA hdsa;
74 
75  TRACE("(size=%d grow=%d)\n", nSize, nGrow);
76 
77  hdsa = Alloc (sizeof(*hdsa));
78  if (hdsa)
79  {
80  hdsa->nItemCount = 0;
81  hdsa->pData = NULL;
82  hdsa->nMaxCount = 0;
83  hdsa->nItemSize = nSize;
84  hdsa->nGrow = max(1, nGrow);
85  }
86 
87  return hdsa;
88 }
INT nItemSize
Definition: dsa.c:49
#define max(a, b)
Definition: svc.c:63
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
Definition: dsa.c:44
LPVOID pData
Definition: dsa.c:47
INT nMaxCount
Definition: dsa.c:48
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
INT nGrow
Definition: dsa.c:50
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
INT nItemCount
Definition: dsa.c:46

Referenced by CEnumMergedFolder::Begin(), CComCatCachedCategory::CComCatCachedCategory(), CSHEnumClassesOfCategories::CSHEnumClassesOfCategories(), DSA_Clone(), and CShellBrowser::Initialize().

◆ DSA_DeleteAllItems()

BOOL WINAPI DSA_DeleteAllItems ( HDSA  hdsa)

Definition at line 367 of file dsa.c.

368 {
369  TRACE("(%p)\n", hdsa);
370 
371  if (!hdsa)
372  return FALSE;
373  if (hdsa->pData && (!Free (hdsa->pData)))
374  return FALSE;
375 
376  hdsa->nItemCount = 0;
377  hdsa->pData = NULL;
378  hdsa->nMaxCount = 0;
379 
380  return TRUE;
381 }
#define TRUE
Definition: types.h:120
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:656
LPVOID pData
Definition: dsa.c:47
INT nMaxCount
Definition: dsa.c:48
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
INT nItemCount
Definition: dsa.c:46

Referenced by CEnumMergedFolder::Begin(), and CShellBrowser::BuildExplorerBandMenu().

◆ DSA_DeleteItem()

INT WINAPI DSA_DeleteItem ( HDSA  hdsa,
INT  nIndex 
)

Definition at line 315 of file dsa.c.

316 {
317  LPVOID lpDest,lpSrc;
318  INT nSize;
319 
320  TRACE("(%p %d)\n", hdsa, nIndex);
321 
322  if (!hdsa)
323  return -1;
324  if (nIndex < 0 || nIndex >= hdsa->nItemCount)
325  return -1;
326 
327  /* do we need to move ? */
328  if (nIndex < hdsa->nItemCount - 1) {
329  lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
330  lpSrc = (char *) lpDest + hdsa->nItemSize;
331  nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
332  TRACE("-- move dest=%p src=%p size=%d\n",
333  lpDest, lpSrc, nSize);
334  memmove (lpDest, lpSrc, nSize);
335  }
336 
337  hdsa->nItemCount--;
338 
339  /* free memory ? */
340  if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
341  nSize = hdsa->nItemSize * hdsa->nItemCount;
342 
343  lpDest = ReAlloc (hdsa->pData, nSize);
344  if (!lpDest)
345  return -1;
346 
347  hdsa->nMaxCount = hdsa->nItemCount;
348  hdsa->pData = lpDest;
349  }
350 
351  return nIndex;
352 }
INT nItemSize
Definition: dsa.c:49
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
int32_t INT
Definition: typedefs.h:56
LPVOID pData
Definition: dsa.c:47
INT nMaxCount
Definition: dsa.c:48
#define TRACE(s)
Definition: solgame.cpp:4
PVOID ReAlloc(IN DWORD dwFlags, IN PVOID lpMem, IN SIZE_T dwBytes)
Definition: main.c:76
INT nGrow
Definition: dsa.c:50
INT nItemCount
Definition: dsa.c:46

◆ DSA_Destroy()

BOOL WINAPI DSA_Destroy ( HDSA  hdsa)

Definition at line 103 of file dsa.c.

104 {
105  TRACE("(%p)\n", hdsa);
106 
107  if (!hdsa)
108  return FALSE;
109 
110  if (hdsa->pData && (!Free (hdsa->pData)))
111  return FALSE;
112 
113  return Free (hdsa);
114 }
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:656
LPVOID pData
Definition: dsa.c:47
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by DSA_Clone(), DSA_DestroyCallback(), CComCatCachedCategory::~CComCatCachedCategory(), CShellBrowser::~CShellBrowser(), and CSHEnumClassesOfCategories::~CSHEnumClassesOfCategories().

◆ DSA_DestroyCallback()

void WINAPI DSA_DestroyCallback ( HDSA  hdsa,
PFNDSAENUMCALLBACK  enumProc,
LPVOID  lParam 
)

Definition at line 432 of file dsa.c.

434 {
435  TRACE("(%p %p %p)\n", hdsa, enumProc, lParam);
436 
437  DSA_EnumCallback (hdsa, enumProc, lParam);
438  DSA_Destroy (hdsa);
439 }
VOID WINAPI DSA_EnumCallback(HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dsa.c:397
BOOL WINAPI DSA_Destroy(HDSA hdsa)
Definition: dsa.c:103
#define TRACE(s)
Definition: solgame.cpp:4
LPARAM lParam
Definition: combotst.c:139

Referenced by SHFreeNameMappings(), and CEnumMergedFolder::~CEnumMergedFolder().

◆ DSA_EnumCallback()

VOID WINAPI DSA_EnumCallback ( HDSA  hdsa,
PFNDSAENUMCALLBACK  enumProc,
LPVOID  lParam 
)

Definition at line 397 of file dsa.c.

399 {
400  INT i;
401 
402  TRACE("(%p %p %p)\n", hdsa, enumProc, lParam);
403 
404  if (!hdsa)
405  return;
406  if (hdsa->nItemCount <= 0)
407  return;
408 
409  for (i = 0; i < hdsa->nItemCount; i++) {
410  LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
411  if ((enumProc)(lpItem, lParam) == 0)
412  return;
413  }
414 
415  return;
416 }
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
LPVOID WINAPI DSA_GetItemPtr(HDSA hdsa, INT nIndex)
Definition: dsa.c:162
INT nItemCount
Definition: dsa.c:46
LPARAM lParam
Definition: combotst.c:139

Referenced by CEnumMergedFolder::Begin(), and DSA_DestroyCallback().

◆ DSA_GetItem()

BOOL WINAPI DSA_GetItem ( HDSA  hdsa,
INT  nIndex,
LPVOID  pDest 
)

Definition at line 131 of file dsa.c.

132 {
133  LPVOID pSrc;
134 
135  TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
136 
137  if (!hdsa)
138  return FALSE;
139  if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
140  return FALSE;
141 
142  pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
143  memmove (pDest, pSrc, hdsa->nItemSize);
144 
145  return TRUE;
146 }
INT nItemSize
Definition: dsa.c:49
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
LPVOID pData
Definition: dsa.c:47
#define TRACE(s)
Definition: solgame.cpp:4
INT nItemCount
Definition: dsa.c:46

◆ DSA_GetItemPtr()

LPVOID WINAPI DSA_GetItemPtr ( HDSA  hdsa,
INT  nIndex 
)

Definition at line 162 of file dsa.c.

163 {
164  LPVOID pSrc;
165 
166  TRACE("(%p %d)\n", hdsa, nIndex);
167 
168  if (!hdsa)
169  return NULL;
170  if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
171  return NULL;
172 
173  pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
174 
175  TRACE("-- ret=%p\n", pSrc);
176 
177  return pSrc;
178 }
INT nItemSize
Definition: dsa.c:49
LPVOID pData
Definition: dsa.c:47
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
INT nItemCount
Definition: dsa.c:46

Referenced by CEnumMergedFolder::Begin(), CComCatCachedCategory::CacheDSA(), DSA_Clone(), DSA_EnumCallback(), CEnumMergedFolder::FindByName(), CEnumMergedFolder::FindPidlInList(), CEnumMergedFolder::Next(), CSHEnumClassesOfCategories::Next(), CShellBrowser::OnExplorerBar(), and CComCatCachedCategory::WriteCacheToDSA().

◆ DSA_GetSize()

ULONGLONG WINAPI DSA_GetSize ( HDSA  hdsa)

Definition at line 488 of file dsa.c.

489 {
490  TRACE("(%p)\n", hdsa);
491 
492  if (!hdsa) return 0;
493 
494  return sizeof(*hdsa) + (ULONGLONG)hdsa->nMaxCount*hdsa->nItemSize;
495 }
INT nItemSize
Definition: dsa.c:49
INT nMaxCount
Definition: dsa.c:48
#define TRACE(s)
Definition: solgame.cpp:4
uint64_t ULONGLONG
Definition: typedefs.h:65

◆ DSA_InsertItem()

INT WINAPI DSA_InsertItem ( HDSA  hdsa,
INT  nIndex,
LPVOID  pSrc 
)

Definition at line 251 of file dsa.c.

252 {
253  INT nNewItems, nSize;
254  LPVOID lpTemp, lpDest;
255 
256  TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
257 
258  if ((!hdsa) || nIndex < 0)
259  return -1;
260 
261  /* when nIndex >= nItemCount then append */
262  if (nIndex >= hdsa->nItemCount)
263  nIndex = hdsa->nItemCount;
264 
265  /* do we need to resize ? */
266  if (hdsa->nItemCount >= hdsa->nMaxCount) {
267  nNewItems = hdsa->nMaxCount + hdsa->nGrow;
268  nSize = hdsa->nItemSize * nNewItems;
269 
270  if (nSize / hdsa->nItemSize != nNewItems)
271  return -1;
272 
273  lpTemp = ReAlloc (hdsa->pData, nSize);
274  if (!lpTemp)
275  return -1;
276 
277  hdsa->nMaxCount = nNewItems;
278  hdsa->pData = lpTemp;
279  }
280 
281  /* do we need to move elements ? */
282  if (nIndex < hdsa->nItemCount) {
283  lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
284  lpDest = (char *) lpTemp + hdsa->nItemSize;
285  nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
286  TRACE("-- move dest=%p src=%p size=%d\n",
287  lpDest, lpTemp, nSize);
288  memmove (lpDest, lpTemp, nSize);
289  }
290 
291  /* ok, we can put the new Item in */
292  hdsa->nItemCount++;
293  lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
294  TRACE("-- move dest=%p src=%p size=%d\n",
295  lpDest, pSrc, hdsa->nItemSize);
296  memmove (lpDest, pSrc, hdsa->nItemSize);
297 
298  return nIndex;
299 }
INT nItemSize
Definition: dsa.c:49
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
int32_t INT
Definition: typedefs.h:56
LPVOID pData
Definition: dsa.c:47
INT nMaxCount
Definition: dsa.c:48
#define TRACE(s)
Definition: solgame.cpp:4
PVOID ReAlloc(IN DWORD dwFlags, IN PVOID lpMem, IN SIZE_T dwBytes)
Definition: main.c:76
INT nGrow
Definition: dsa.c:50
INT nItemCount
Definition: dsa.c:46

Referenced by CEnumMergedFolder::Begin(), DSA_Clone(), CComCatCachedCategory::LoadFromComCatMgr(), CComCatCachedCategory::LoadFromRegistry(), and CComCatCachedCategory::WriteCacheToDSA().

◆ DSA_SetItem()

BOOL WINAPI DSA_SetItem ( HDSA  hdsa,
INT  nIndex,
LPVOID  pSrc 
)

Definition at line 195 of file dsa.c.

196 {
197  INT nSize, nNewItems;
198  LPVOID pDest, lpTemp;
199 
200  TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
201 
202  if ((!hdsa) || nIndex < 0)
203  return FALSE;
204 
205  if (hdsa->nItemCount <= nIndex) {
206  /* within the old array */
207  if (hdsa->nMaxCount > nIndex) {
208  /* within the allocated space, set a new boundary */
209  hdsa->nItemCount = nIndex + 1;
210  }
211  else {
212  /* resize the block of memory */
213  nNewItems =
214  hdsa->nGrow * ((((nIndex + 1) - 1) / hdsa->nGrow) + 1);
215  nSize = hdsa->nItemSize * nNewItems;
216 
217  lpTemp = ReAlloc (hdsa->pData, nSize);
218  if (!lpTemp)
219  return FALSE;
220 
221  hdsa->nMaxCount = nNewItems;
222  hdsa->nItemCount = nIndex + 1;
223  hdsa->pData = lpTemp;
224  }
225  }
226 
227  /* put the new entry in */
228  pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
229  TRACE("-- move dest=%p src=%p size=%d\n",
230  pDest, pSrc, hdsa->nItemSize);
231  memmove (pDest, pSrc, hdsa->nItemSize);
232 
233  return TRUE;
234 }
INT nItemSize
Definition: dsa.c:49
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
int32_t INT
Definition: typedefs.h:56
LPVOID pData
Definition: dsa.c:47
INT nMaxCount
Definition: dsa.c:48
#define TRACE(s)
Definition: solgame.cpp:4
PVOID ReAlloc(IN DWORD dwFlags, IN PVOID lpMem, IN SIZE_T dwBytes)
Definition: main.c:76
INT nGrow
Definition: dsa.c:50
INT nItemCount
Definition: dsa.c:46

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dsa  )