crypt32(4/17): Add base message type and use it to implement...
Juan Lang
juan.lang at gmail.com
Thu Jun 28 19:27:25 CDT 2007
Skipped content of type multipart/alternative-------------- next part --------------
From 29b613df4dd3dfc038e9af70117c88aba4804257 Mon Sep 17 00:00:00 2001
From: Juan Lang <juanlang at juan.corp.google.com>
Date: Thu, 28 Jun 2007 16:45:29 -0700
Subject: [PATCH] Add base message type, and use it to implement CryptMsgDuplicate and
CryptMsgClose
---
dlls/crypt32/msg.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index df891f4..f7f1474 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -25,6 +25,24 @@ #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
+/* Called when a message's ref count reaches zero. Free any message-specific
+ * data here.
+ */
+typedef void (*CryptMsgCloseFunc)(HCRYPTMSG msg);
+
+typedef struct _CryptMsgBase
+{
+ LONG ref;
+ DWORD open_flags;
+ CryptMsgCloseFunc close;
+} CryptMsgBase;
+
+static inline void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags)
+{
+ msg->ref = 1;
+ msg->open_flags = dwFlags;
+}
+
static inline const char *MSG_TYPE_STR(DWORD type)
{
static char buf[25];
@@ -93,13 +111,33 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DW
HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg)
{
- FIXME("(%p): stub\n", hCryptMsg);
+ TRACE("(%p)\n", hCryptMsg);
+
+ if (hCryptMsg)
+ {
+ CryptMsgBase *msg = (CryptMsgBase *)hCryptMsg;
+
+ InterlockedIncrement(&msg->ref);
+ }
return hCryptMsg;
}
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
{
- FIXME("(%p): stub\n", hCryptMsg);
+ TRACE("(%p)\n", hCryptMsg);
+
+ if (hCryptMsg)
+ {
+ CryptMsgBase *msg = (CryptMsgBase *)hCryptMsg;
+
+ if (InterlockedDecrement(&msg->ref) == 0)
+ {
+ TRACE("freeing %p\n", msg);
+ if (msg->close)
+ msg->close(msg);
+ CryptMemFree(msg);
+ }
+ }
return TRUE;
}
--
1.4.1
More information about the wine-patches
mailing list