Skip to content

Commit 9b78189

Browse files
author
Pavel Kovalenko
committed
Use stack semantics for marshal_context.
1 parent f60f1a0 commit 9b78189

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/editors/xrManagedApi/core/PostProcessAnimator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,16 @@ void PostProcessInfo::ColorMappingInterpolate::set(float value) { impl->cm_inter
7676
String^ PostProcessInfo::ColorMappingGradient1::get() { return gcnew String(impl->cm_tex1.c_str()); }
7777
void PostProcessInfo::ColorMappingGradient1::set(String^ value)
7878
{
79-
auto context = gcnew marshal_context();
80-
auto tmpStr = context->marshal_as<const char*>(value);
79+
marshal_context context;
80+
auto tmpStr = context.marshal_as<const char*>(value);
8181
impl->cm_tex1 = tmpStr;
82-
delete context;
8382
}
8483
String^ PostProcessInfo::ColorMappingGradient2::get() { return gcnew String(impl->cm_tex2.c_str()); }
8584
void PostProcessInfo::ColorMappingGradient2::set(String^ value)
8685
{
87-
auto context = gcnew marshal_context();
88-
auto tmpStr = context->marshal_as<const char*>(value);
86+
marshal_context context;
87+
auto tmpStr = context.marshal_as<const char*>(value);
8988
impl->cm_tex2 = tmpStr;
90-
delete context;
9189
}
9290
PostProcessInfo::PostProcessInfo(::SPPInfo* impl) { this->impl = impl; }
9391
PostProcessInfo::PostProcessInfo(::SPPInfo* impl, bool dontDestroy) : PostProcessInfo(impl)

src/editors/xrManagedApi/core/fs/FS.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,15 @@ void WriterBase::WriteString(const char* buffer) { impl->w_string(buffer); }
4141
void WriterBase::WriteStringZ(const char* buffer) { impl->w_stringZ(buffer); }
4242
void WriterBase::WriteString(String^ value)
4343
{
44-
auto context = gcnew marshal_context();
45-
auto tmpStr = context->marshal_as<const char*>(value);
44+
marshal_context context;
45+
auto tmpStr = context.marshal_as<const char*>(value);
4646
impl->w_string(tmpStr);
47-
delete context;
4847
}
4948
void WriterBase::WriteStringZ(String^ value)
5049
{
51-
auto context = gcnew marshal_context();
52-
auto tmpStr = context->marshal_as<const char*>(value);
50+
marshal_context context;
51+
auto tmpStr = context.marshal_as<const char*>(value);
5352
impl->w_stringZ(tmpStr);
54-
delete context;
5553
}
5654
void WriterBase::WriteColorF(ColorF value) { impl->w_fcolor((const Fcolor&)value); }
5755
void WriterBase::WriteVector4F(Vector4F value) { impl->w_fvector4((const Fvector4&)value); }
@@ -69,10 +67,9 @@ void WriterBase::WriteScaledDirection(Vector3F value) { impl->w_sdir((const Fvec
6967
void WriterBase::WriteString(String^ format, ... array<Object^>^ args)
7068
{
7169
auto str = String::Format(format, args);
72-
auto context = gcnew marshal_context();
73-
auto tmpStr = context->marshal_as<const char*>(str);
70+
marshal_context context;
71+
auto tmpStr = context.marshal_as<const char*>(str);
7472
impl->w(tmpStr, xr_strlen(tmpStr));
75-
delete context;
7673
}
7774
void WriterBase::OpenChunk(UInt32 type) { impl->open_chunk(type); }
7875
void WriterBase::CloseChunk() { impl->close_chunk(); }

0 commit comments

Comments
 (0)