Kaydet (Commit) 06e0aff6 authored tarafından Caolán McNamara's avatar Caolán McNamara

can return a ref, not a pointer, and make local static instead of global leak

üst 90e9a26a
......@@ -28,13 +28,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
#include <string.h>
#include <tools/debug.hxx>
#include <rtl/instance.hxx>
#include "psputil.hxx"
#include "tools/debug.hxx"
namespace psp {
/*
......@@ -254,15 +252,17 @@ ConverterFactory::Convert (const sal_Unicode *pText, int nTextLen,
return nSize;
}
ConverterFactory*
GetConverterFactory ()
namespace
{
static ConverterFactory* pCvt = NULL;
if (pCvt == NULL)
pCvt = new ConverterFactory;
class theConverterFactory
: public rtl::Static<ConverterFactory, theConverterFactory>
{
};
}
return pCvt;
ConverterFactory& GetConverterFactory()
{
return theConverterFactory::get();
}
......
......@@ -71,7 +71,7 @@ private:
std::map< rtl_TextEncoding, rtl_UnicodeToTextConverter > m_aConverters;
};
ConverterFactory* GetConverterFactory ();
ConverterFactory& GetConverterFactory ();
} /* namespace psp */
......
......@@ -583,8 +583,8 @@ PrinterGfx::LicenseWarning(const Point& rPoint, const sal_Unicode* pStr,
sal_Size nSize = 4 * nLen;
sal_uChar* pBuffer = (sal_uChar*)alloca (nSize* sizeof(sal_uChar));
ConverterFactory* pCvt = GetConverterFactory ();
nSize = pCvt->Convert (pStr, nLen, pBuffer, nSize, RTL_TEXTENCODING_ISO_8859_1);
ConverterFactory &rCvt = GetConverterFactory ();
nSize = rCvt.Convert (pStr, nLen, pBuffer, nSize, RTL_TEXTENCODING_ISO_8859_1);
PSMoveTo (rPoint);
PSShowText (pBuffer, nLen, nSize, pDeltaArray);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment