Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
LibVLCSharp
Commits
d709e6d9
Commit
d709e6d9
authored
May 06, 2020
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call AllocHGlobal in the try/catch
parent
37c43bac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
src/LibVLCSharp/Shared/Helpers/MarshalExtensions.cs
src/LibVLCSharp/Shared/Helpers/MarshalExtensions.cs
+2
-1
src/LibVLCSharp/Shared/Helpers/MarshalUtils.cs
src/LibVLCSharp/Shared/Helpers/MarshalUtils.cs
+2
-1
No files found.
src/LibVLCSharp/Shared/Helpers/MarshalExtensions.cs
View file @
d709e6d9
...
...
@@ -127,9 +127,10 @@ namespace LibVLCSharp.Shared.Helpers
return
IntPtr
.
Zero
;
var
bytes
=
Encoding
.
UTF8
.
GetBytes
(
str
);
var
nativeString
=
Marshal
.
AllocHGlobal
(
bytes
.
Length
+
1
)
;
var
nativeString
=
IntPtr
.
Zero
;
try
{
nativeString
=
Marshal
.
AllocHGlobal
(
bytes
.
Length
+
1
);
Marshal
.
Copy
(
bytes
,
0
,
nativeString
,
bytes
.
Length
);
Marshal
.
WriteByte
(
nativeString
,
bytes
.
Length
,
0
);
}
...
...
src/LibVLCSharp/Shared/Helpers/MarshalUtils.cs
View file @
d709e6d9
...
...
@@ -154,9 +154,10 @@ namespace LibVLCSharp.Shared.Helpers
static
void
UseStructurePointer
<
T
>(
T
structure
,
Action
<
IntPtr
>
action
)
{
var
structurePointer
=
Marshal
.
AllocHGlobal
(
Marshal
.
SizeOf
(
structure
))
;
var
structurePointer
=
IntPtr
.
Zero
;
try
{
structurePointer
=
Marshal
.
AllocHGlobal
(
Marshal
.
SizeOf
(
structure
));
Marshal
.
StructureToPtr
(
structure
,
structurePointer
,
false
);
action
(
structurePointer
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment