summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx4
-rw-r--r--include/rtl/alloc.h30
-rw-r--r--sal/qa/rtl/alloc/rtl_alloc.cxx4
-rw-r--r--sal/rtl/strimp.cxx46
4 files changed, 25 insertions, 59 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 04f586ce4eb3..3af3b54d015f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3815,9 +3815,9 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
return 1;
if (eStage == PRE_INIT)
- rtl_alloc_preInit(rtlAllocPreInitStart);
+ rtl_alloc_preInit(true);
else if (eStage == SECOND_INIT)
- rtl_alloc_preInit(rtlAllocPreInitEnd);
+ rtl_alloc_preInit(false);
if (eStage != SECOND_INIT)
comphelper::LibreOfficeKit::setActive();
diff --git a/include/rtl/alloc.h b/include/rtl/alloc.h
index cc3cec6ef292..74d4ea5c4339 100644
--- a/include/rtl/alloc.h
+++ b/include/rtl/alloc.h
@@ -289,38 +289,14 @@ SAL_DLLPUBLIC void SAL_CALL rtl_cache_free (
#ifdef LIBO_INTERNAL_ONLY
/** @cond INTERNAL */
-/** rtl_alloc_preInit_phase_t
- *
- * This is used to control the pre-init logic
- * in rtl_alloc_preInit. The reason for this is
- * to first initialize all caching and other memory
- * logic from WSD (the Online daemon) at startup.
- * All these pages will then be forked over when
- * spawning per-document instances. This is done
- * by calling rtl_alloc_preInit with rtlAllocPreInitStart.
- *
- * @since LibreOffice 6.1
- */
-typedef enum
-{
- // Start phase I of pre-init.
- rtlAllocPreInitStart,
- // Finish phase I of pre-init (before forking).
- rtlAllocPreInitEnd,
- // Post pre-init and after forking; no longer used.
- rtlAllocPostInit
-
-} rtl_alloc_preInit_phase_t;
-
-/** @cond INTERNAL */
/** rtl_alloc_preInit
*
* This function, is called at the beginning and again
* at the end of LibreOfficeKit pre-initialization to enable
* various optimizations.
*
- * Its function is to annotate a section @phase = rtlAllocPreInitStart
- * to end (@phase = rtlAllocPreInitEnd) via. two calls. Inside this
+ * Its function is to annotate a section @start = true
+ * to end (@start = false) via. two calls. Inside this
* section string allocators are replaced with ones which cause the
* strings to be staticized at the end of the section.
*
@@ -341,7 +317,7 @@ typedef enum
* @since LibreOffice 6.1
*/
SAL_DLLPUBLIC void SAL_CALL rtl_alloc_preInit (
- rtl_alloc_preInit_phase_t phase
+ sal_Bool start
) SAL_THROW_EXTERN_C();
/** @endcond */
diff --git a/sal/qa/rtl/alloc/rtl_alloc.cxx b/sal/qa/rtl/alloc/rtl_alloc.cxx
index 37c7b41eb338..0e9b7c0f47a8 100644
--- a/sal/qa/rtl/alloc/rtl_alloc.cxx
+++ b/sal/qa/rtl/alloc/rtl_alloc.cxx
@@ -158,7 +158,7 @@ public:
const char *sample = "Hello World";
std::vector<OUString> aStrings;
- rtl_alloc_preInit(rtlAllocPreInitStart);
+ rtl_alloc_preInit(true);
OUString aFoo("foo");
@@ -183,7 +183,7 @@ public:
}
// should static-ize all the strings.
- rtl_alloc_preInit(rtlAllocPreInitEnd);
+ rtl_alloc_preInit(false);
for (size_t i = 0; i < aStrings.size(); ++i)
CPPUNIT_ASSERT_MESSAGE( "static after.", (aStrings[i].pData->refCount & SAL_STRING_STATIC_FLAG) );
diff --git a/sal/rtl/strimp.cxx b/sal/rtl/strimp.cxx
index e356a4e921a6..d1651a2ad1d7 100644
--- a/sal/rtl/strimp.cxx
+++ b/sal/rtl/strimp.cxx
@@ -94,36 +94,26 @@ static void mark_static(void *addr, sal_Size /* size */)
str->refCount |= SAL_STRING_STATIC_FLAG;
}
-void SAL_CALL rtl_alloc_preInit (rtl_alloc_preInit_phase_t phase) SAL_THROW_EXTERN_C()
+void SAL_CALL rtl_alloc_preInit (sal_Bool start) SAL_THROW_EXTERN_C()
{
- switch (phase)
+ if (start)
{
- case rtlAllocPreInitStart:
- {
- rtl_allocateString = pre_allocateStringFn;
- rtl_freeString = pre_freeStringFn;
- pre_arena = rtl_arena_create("pre-init strings", 4, 0,
- nullptr, rtl_arena_alloc,
- rtl_arena_free, 0);
-
- // To be consistent (and to ensure the rtl_cache threads are started).
- ensureCacheSingleton();
- }
- break;
-
- case rtlAllocPreInitEnd:
- // back to normal
- {
- rtl_arena_foreach(pre_arena, mark_static);
- rtl_allocateString = rtl_allocateMemory;
- rtl_freeString = rtl_freeMemory;
-
- // TODO: also re-initialize main allocator as well.
- }
- break;
-
- case rtlAllocPostInit: // no longer used
- break;
+ rtl_allocateString = pre_allocateStringFn;
+ rtl_freeString = pre_freeStringFn;
+ pre_arena = rtl_arena_create("pre-init strings", 4, 0,
+ nullptr, rtl_arena_alloc,
+ rtl_arena_free, 0);
+
+ // To be consistent (and to ensure the rtl_cache threads are started).
+ ensureCacheSingleton();
+ }
+ else
+ {
+ rtl_arena_foreach(pre_arena, mark_static);
+ rtl_allocateString = rtl_allocateMemory;
+ rtl_freeString = rtl_freeMemory;
+
+ // TODO: also re-initialize main allocator as well.
}
}