summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-03 18:03:31 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-08-01 17:24:25 +0200
commitaeeb6d5206e813b037a3957aa8fb94c490d2729d (patch)
tree7c9129df98fa3ed5ad696df081d3a5946ffd72ba /sal
parent0c00f6490951ee73748fae74998edf0a7ef589fa (diff)
Replace rtl_cache_alloc/free with rtl_allocate/freeMemory
...as with the combination of old ce906b8096081dee15dc8cc96e570d5b0b587955 "skip tricky allocators on G_SLICE=always-malloc" and recent bc6a5d8e79e7d0e7d75ac107aa8e6aa275e434e9 "Disable custom allocator", rtl_cache unconditionally just uses malloc/free now (see also db354dfad541fe2edd64a618a2d7cc83a6be2b9e "the custom SAL allocator is no longer used" and df6ba650469a6f2fda06ef1c2e107ccdd3570505 "Remove 'officially dead now' rtl_cache slab allocator mechanism"). So simplify the code. Change-Id: Ia665fd381ee4757e2c8b3d0460363bd34efd373a Reviewed-on: https://gerrit.libreoffice.org/58424 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file.cxx74
-rw-r--r--sal/osl/w32/file.cxx65
2 files changed, 12 insertions, 127 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 94aa6e42fc8a..ae221a8834a6 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -142,26 +142,6 @@ struct FileHandle_Impl
oslFileError syncFile();
- /** Buffer cache / allocator.
- */
- class Allocator
- {
- rtl_cache_type* m_cache;
- size_t m_bufsiz;
-
- public:
- Allocator(const Allocator&) = delete;
- Allocator& operator=(const Allocator&) = delete;
- static Allocator& get();
-
- void allocate(sal_uInt8 **ppBuffer, size_t *pnSize);
- void deallocate(sal_uInt8 *pBuffer);
-
- protected:
- Allocator();
- ~Allocator();
- };
-
class Guard
{
pthread_mutex_t *m_mutex;
@@ -172,47 +152,6 @@ struct FileHandle_Impl
};
};
-FileHandle_Impl::Allocator& FileHandle_Impl::Allocator::get()
-{
- static Allocator g_aBufferAllocator;
- return g_aBufferAllocator;
-}
-
-FileHandle_Impl::Allocator::Allocator()
- : m_cache(nullptr),
- m_bufsiz(0)
-{
- size_t const pagesize = FileHandle_Impl::getpagesize();
- if (pagesize != size_t(-1))
- {
- m_cache = rtl_cache_create(
- "osl_file_buffer_cache", pagesize, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0);
-
- if (m_cache)
- m_bufsiz = pagesize;
- }
-}
-
-FileHandle_Impl::Allocator::~Allocator()
-{
- rtl_cache_destroy(m_cache);
- m_cache = nullptr;
-}
-
-void FileHandle_Impl::Allocator::allocate(sal_uInt8 **ppBuffer, size_t *pnSize)
-{
- assert(ppBuffer);
- assert(pnSize);
- *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache));
- *pnSize = m_bufsiz;
-}
-
-void FileHandle_Impl::Allocator::deallocate(sal_uInt8 * pBuffer)
-{
- if (pBuffer)
- rtl_cache_free(m_cache, pBuffer);
-}
-
FileHandle_Impl::Guard::Guard(pthread_mutex_t * pMutex)
: m_mutex(pMutex)
{
@@ -243,9 +182,14 @@ FileHandle_Impl::FileHandle_Impl(int fd, enum Kind kind, char const * path)
rtl_string_newFromStr(&m_strFilePath, path);
if (m_kind == KIND_FD)
{
- Allocator::get().allocate (&m_buffer, &m_bufsiz);
- if (m_buffer)
- memset(m_buffer, 0, m_bufsiz);
+ size_t const pagesize = getpagesize();
+ if (pagesize != size_t(-1))
+ {
+ m_bufsiz = pagesize;
+ m_buffer = static_cast<sal_uInt8 *>(rtl_allocateMemory(m_bufsiz));
+ if (m_buffer)
+ memset(m_buffer, 0, m_bufsiz);
+ }
}
}
@@ -253,7 +197,7 @@ FileHandle_Impl::~FileHandle_Impl()
{
if (m_kind == KIND_FD)
{
- Allocator::get().deallocate(m_buffer);
+ rtl_freeMemory(m_buffer);
m_buffer = nullptr;
}
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index a63b58a1bdca..35373bb56cc2 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -116,27 +116,6 @@ struct FileHandle_Impl
oslFileError syncFile();
- /** Buffer cache / allocator.
- */
- class Allocator
- {
- rtl_cache_type * m_cache;
- SIZE_T m_bufsiz;
-
- Allocator(Allocator const &) = delete;
- Allocator & operator= (Allocator const &) = delete;
-
- public:
- static Allocator & get();
-
- void allocate(sal_uInt8 ** ppBuffer, SIZE_T * pnSize);
- void deallocate(sal_uInt8 * pBuffer);
-
- protected:
- Allocator();
- ~Allocator();
- };
-
/** Guard.
*/
class Guard
@@ -149,44 +128,6 @@ struct FileHandle_Impl
};
};
-FileHandle_Impl::Allocator& FileHandle_Impl::Allocator::get()
-{
- static Allocator g_aBufferAllocator;
- return g_aBufferAllocator;
-}
-
-FileHandle_Impl::Allocator::Allocator()
- : m_cache (nullptr),
- m_bufsiz (0)
-{
- SIZE_T const pagesize = FileHandle_Impl::getpagesize();
- m_cache = rtl_cache_create(
- "osl_file_buffer_cache", pagesize, 0, nullptr, nullptr, nullptr,
- nullptr, nullptr, 0);
- if (m_cache)
- m_bufsiz = pagesize;
-}
-
-FileHandle_Impl::Allocator::~Allocator()
-{
- rtl_cache_destroy(m_cache);
- m_cache = nullptr;
-}
-
-void FileHandle_Impl::Allocator::allocate (sal_uInt8 **ppBuffer, SIZE_T * pnSize)
-{
- assert(ppBuffer);
- assert(pnSize);
- *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache));
- *pnSize = m_bufsiz;
-}
-
-void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
-{
- if (pBuffer)
- rtl_cache_free (m_cache, pBuffer);
-}
-
FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex)
: m_mutex (pMutex)
{
@@ -207,18 +148,18 @@ FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
m_filepos (0),
m_bufptr (-1),
m_buflen (0),
- m_bufsiz (0),
+ m_bufsiz (getpagesize()),
m_buffer (nullptr)
{
::InitializeCriticalSection (&m_mutex);
- Allocator::get().allocate (&m_buffer, &m_bufsiz);
+ m_buffer = static_cast<sal_uInt8 *>(rtl_allocateMemory(m_bufsiz));
if (m_buffer)
memset (m_buffer, 0, m_bufsiz);
}
FileHandle_Impl::~FileHandle_Impl()
{
- Allocator::get().deallocate(m_buffer);
+ rtl_freeMemory(m_buffer);
m_buffer = nullptr;
::DeleteCriticalSection (&m_mutex);
}