summaryrefslogtreecommitdiff
path: root/plugins/ExternalAPI/m_variables.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-02-21 13:03:09 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-02-21 13:03:09 +0000
commit1c44f2df0725c7673b0522121461337270cd47c6 (patch)
tree73979ab4ed3fcdf367ccce10ba1811def67d69b6 /plugins/ExternalAPI/m_variables.h
parent1f59d862f624b14135eaf16899d3bc617fa3ff1e (diff)
service MS_VARS_FREEMEMORY replaced with the direct call of mir_free
git-svn-id: http://svn.miranda-ng.org/main/trunk@3669 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ExternalAPI/m_variables.h')
-rw-r--r--plugins/ExternalAPI/m_variables.h101
1 files changed, 28 insertions, 73 deletions
diff --git a/plugins/ExternalAPI/m_variables.h b/plugins/ExternalAPI/m_variables.h
index 77b3407291..a352084b20 100644
--- a/plugins/ExternalAPI/m_variables.h
+++ b/plugins/ExternalAPI/m_variables.h
@@ -37,37 +37,6 @@
#endif
// --------------------------------------------------------------------------
-// Memory management
-// --------------------------------------------------------------------------
-
-// Release memory that was allocated by the Variables plugin, e.g. returned
-// strings.
-
-#define MS_VARS_FREEMEMORY "Vars/FreeMemory"
-
-// Parameters:
-// ------------------------
-// wParam = (WPARAM)(void *)pntr
-// Pointer to memory that was allocated by the Variables plugin (e.g. a
-// returned string) (can be NULL).
-// lParam = 0
-
-// Return Value:
-// ------------------------
-// Does return 0 on success, nozero otherwise.
-
-// Note: Do only use this service to free memory that was *explicitliy*
-// stated that it should be free with this service.
-
-// Helper function for easy using:
-#ifndef VARIABLES_NOHELPER
-__inline static void variables_free(void *pntr) {
-
- CallService(MS_VARS_FREEMEMORY, (WPARAM)pntr, 0);
-}
-#endif
-
-// --------------------------------------------------------------------------
// String formatting
// --------------------------------------------------------------------------
@@ -180,51 +149,37 @@ __inline static TCHAR *variables_parse_ex(TCHAR *tszFormat, TCHAR *tszExtraText,
// Note: The returned pointer needs to be released using your own free().
#ifndef VARIABLES_NOHELPER
-__inline static TCHAR *variables_parsedup(TCHAR *tszFormat, TCHAR *tszExtraText, HANDLE hContact) {
-
- if (ServiceExists(MS_VARS_FORMATSTRING)) {
- FORMATINFO fi;
- TCHAR *tszParsed, *tszResult;
-
- ZeroMemory(&fi, sizeof(fi));
- fi.cbSize = sizeof(fi);
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
- fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (tszParsed) {
- tszResult = mir_tstrdup(tszParsed);
- CallService(MS_VARS_FREEMEMORY, (WPARAM)tszParsed, 0);
- return tszResult;
- }
- }
- return tszFormat?mir_tstrdup(tszFormat):tszFormat;
+__inline static TCHAR *variables_parsedup(TCHAR *tszFormat, TCHAR *tszExtraText, HANDLE hContact)
+{
+ if ( ServiceExists(MS_VARS_FORMATSTRING)) {
+ FORMATINFO fi = { sizeof(fi) };
+ fi.tszFormat = tszFormat;
+ fi.tszExtraText = tszExtraText;
+ fi.hContact = hContact;
+ fi.flags |= FIF_TCHAR;
+ TCHAR *tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ if (tszParsed)
+ return tszParsed;
+ }
+ return tszFormat ? mir_tstrdup(tszFormat) : tszFormat;
}
__inline static TCHAR *variables_parsedup_ex(TCHAR *tszFormat, TCHAR *tszExtraText, HANDLE hContact,
- TCHAR **tszaTemporaryVars, int cbTemporaryVarsSize) {
-
- if (ServiceExists(MS_VARS_FORMATSTRING)) {
- FORMATINFO fi;
- TCHAR *tszParsed, *tszResult;
-
- ZeroMemory(&fi, sizeof(fi));
- fi.cbSize = sizeof(fi);
- fi.tszFormat = tszFormat;
- fi.tszExtraText = tszExtraText;
- fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- fi.tszaTemporaryVars = tszaTemporaryVars;
- fi.cbTemporaryVarsSize = cbTemporaryVarsSize;
- tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (tszParsed) {
- tszResult = mir_tstrdup(tszParsed);
- CallService(MS_VARS_FREEMEMORY, (WPARAM)tszParsed, 0);
- return tszResult;
- }
- }
- return tszFormat?mir_tstrdup(tszFormat):tszFormat;
+ TCHAR **tszaTemporaryVars, int cbTemporaryVarsSize)
+{
+ if ( ServiceExists(MS_VARS_FORMATSTRING)) {
+ FORMATINFO fi = { sizeof(fi) };
+ fi.tszFormat = tszFormat;
+ fi.tszExtraText = tszExtraText;
+ fi.hContact = hContact;
+ fi.flags |= FIF_TCHAR;
+ fi.tszaTemporaryVars = tszaTemporaryVars;
+ fi.cbTemporaryVarsSize = cbTemporaryVarsSize;
+ TCHAR *tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ if (tszParsed)
+ return tszParsed;
+ }
+ return tszFormat ? mir_tstrdup(tszFormat) : tszFormat;
}
#endif