diff options
author | George Hazan <george.hazan@gmail.com> | 2014-04-01 14:58:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-04-01 14:58:49 +0000 |
commit | 024c7fb409dc9b0c921a41a89a411496a17b0f70 (patch) | |
tree | cc68c2501bbbbfb9975c743b2daf1a4674ece016 /plugins/CryptoPP/src/cpp_cntx.cpp | |
parent | 41b55005fb074c35e5a62f8e8155c4be6edc2f22 (diff) |
CryptoPP: code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8813 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/src/cpp_cntx.cpp')
-rw-r--r-- | plugins/CryptoPP/src/cpp_cntx.cpp | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/plugins/CryptoPP/src/cpp_cntx.cpp b/plugins/CryptoPP/src/cpp_cntx.cpp index 62ee204079..867060daba 100644 --- a/plugins/CryptoPP/src/cpp_cntx.cpp +++ b/plugins/CryptoPP/src/cpp_cntx.cpp @@ -3,14 +3,14 @@ // get context data on context id
pCNTX get_context_on_id(HANDLE context)
{
- if ( context ) {
- pCNTX cntx = (pCNTX) context;
- if ( cntx->header == HEADER && cntx->footer == FOOTER )
+ if (context) {
+ pCNTX cntx = (pCNTX)context;
+ if (cntx->header == HEADER && cntx->footer == FOOTER)
return cntx;
- #if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("get_context_on_id: corrupted context %08X", cntx);
- #endif
+#if defined(_DEBUG) || defined(NETLIB_LOG)
+ Sent_NetLog("get_context_on_id: corrupted context %08X", cntx);
+#endif
}
return NULL;
}
@@ -18,15 +18,14 @@ pCNTX get_context_on_id(HANDLE context) // create context, return context id
HANDLE __cdecl cpp_create_context(int mode)
{
- pCNTX cntx = (pCNTX) malloc(sizeof(CNTX));
- memset(cntx,0,sizeof(CNTX)); // очищаем выделенный блок
+ pCNTX cntx = (pCNTX)malloc(sizeof(CNTX));
+ memset(cntx, 0, sizeof(CNTX)); // очищаем выделенный блок
cntx->header = HEADER;
cntx->footer = FOOTER;
cntx->mode = mode;
return (HANDLE)cntx;
}
-
// delete context
void __cdecl cpp_delete_context(HANDLE context)
{
@@ -37,63 +36,59 @@ void __cdecl cpp_delete_context(HANDLE context) }
}
-
// reset context
void __cdecl cpp_reset_context(HANDLE context)
{
pCNTX tmp = get_context_on_id(context);
- if (tmp) cpp_free_keys(tmp);
+ if (tmp)
+ cpp_free_keys(tmp);
}
-
// allocate pdata
PBYTE cpp_alloc_pdata(pCNTX ptr)
{
- if ( !ptr->pdata ) {
- if ( ptr->mode & MODE_PGP ) {
- ptr->pdata = (PBYTE) malloc(sizeof(PGPDATA));
- memset(ptr->pdata,0,sizeof(PGPDATA));
+ if (!ptr->pdata) {
+ if (ptr->mode & MODE_PGP) {
+ ptr->pdata = (PBYTE)malloc(sizeof(PGPDATA));
+ memset(ptr->pdata, 0, sizeof(PGPDATA));
}
- else if ( ptr->mode & MODE_GPG ) {
- ptr->pdata = (PBYTE) malloc(sizeof(GPGDATA));
- memset(ptr->pdata,0,sizeof(GPGDATA));
+ else if (ptr->mode & MODE_GPG) {
+ ptr->pdata = (PBYTE)malloc(sizeof(GPGDATA));
+ memset(ptr->pdata, 0, sizeof(GPGDATA));
}
- else if ( ptr->mode & MODE_RSA ) {
+ else if (ptr->mode & MODE_RSA) {
rsa_alloc(ptr);
}
else {
- ptr->pdata = (PBYTE) malloc(sizeof(SIMDATA));
- memset(ptr->pdata,0,sizeof(SIMDATA));
+ ptr->pdata = (PBYTE)malloc(sizeof(SIMDATA));
+ memset(ptr->pdata, 0, sizeof(SIMDATA));
}
}
return ptr->pdata;
}
-
// free memory from keys
void cpp_free_keys(pCNTX ptr)
{
replaceStr(ptr->tmp, 0);
cpp_alloc_pdata(ptr);
- if ( ptr->mode & MODE_PGP ) {
- pPGPDATA p = (pPGPDATA) ptr->pdata;
+ if (ptr->mode & MODE_PGP) {
+ pPGPDATA p = (pPGPDATA)ptr->pdata;
SAFE_FREE(p->pgpKeyID);
SAFE_FREE(p->pgpKey);
SAFE_FREE(ptr->pdata);
}
- else
- if ( ptr->mode & MODE_GPG ) {
- pGPGDATA p = (pGPGDATA) ptr->pdata;
+ else if (ptr->mode & MODE_GPG) {
+ pGPGDATA p = (pGPGDATA)ptr->pdata;
SAFE_FREE(p->gpgKeyID);
SAFE_FREE(ptr->pdata);
}
- else
- if ( ptr->mode & MODE_RSA ) {
- rsa_free(ptr);
- SAFE_DELETE(ptr->pdata);
+ else if (ptr->mode & MODE_RSA) {
+ if (rsa_free(ptr))
+ SAFE_DELETE(ptr->pdata);
}
else {
- pSIMDATA p = (pSIMDATA) ptr->pdata;
+ pSIMDATA p = (pSIMDATA)ptr->pdata;
SAFE_FREE(p->PubA);
SAFE_FREE(p->KeyA);
mir_free(p->KeyB);
@@ -103,5 +98,3 @@ void cpp_free_keys(pCNTX ptr) SAFE_FREE(ptr->pdata);
}
}
-
-// EOF
|