File tree Expand file tree Collapse file tree 3 files changed +22
-37
lines changed
Silk.NET.OpenAL.Extensions.Creative
Silk.NET.OpenAL.Extensions.EXT
Silk.NET.OpenAL.Extensions.Enumeration Expand file tree Collapse file tree 3 files changed +22
-37
lines changed Original file line number Diff line number Diff line change 33
44using System ;
55using System . Collections . Generic ;
6- using System . Runtime . InteropServices ;
6+ using System . Linq ;
7+ using System . Text ;
78using Silk . NET . Core . Attributes ;
89using Silk . NET . Core . Contexts ;
910using Silk . NET . Core . Native ;
@@ -36,24 +37,18 @@ public IEnumerable<string> GetStringList(GetEnumerateAllContextStringList param)
3637 unsafe
3738 {
3839 var result = GetStringList ( null , param ) ;
39- if ( result == ( byte * ) 0 )
40- {
41- return new List < string > ( ) ;
42- }
40+ if ( result is null ) return Enumerable . Empty < string > ( ) ;
4341
4442 var strings = new List < string > ( ) ;
4543
4644 var currentPos = result ;
47- while ( true )
45+ while ( * currentPos != ' \0 ' )
4846 {
49- var currentString = Marshal . PtrToStringAnsi ( ( nint ) currentPos ) ;
50- if ( string . IsNullOrEmpty ( currentString ) )
51- {
52- break ;
53- }
47+ var currentLength = ( int ) SilkMarshal . StringLength ( ( nint ) currentPos , NativeStringEncoding . UTF8 ) ;
48+ var currentString = Encoding . UTF8 . GetString ( currentPos , currentLength ) ;
5449
5550 strings . Add ( currentString ) ;
56- currentPos += currentString . Length + 1 ;
51+ currentPos += currentLength + 1 ;
5752 }
5853
5954 return strings ;
Original file line number Diff line number Diff line change 33
44using System ;
55using System . Collections . Generic ;
6- using System . Runtime . InteropServices ;
6+ using System . Linq ;
7+ using System . Text ;
78using Silk . NET . Core . Attributes ;
89using Silk . NET . Core . Contexts ;
910using Silk . NET . Core . Native ;
@@ -37,24 +38,18 @@ public IEnumerable<string> GetStringList(GetCaptureContextStringList param)
3738 unsafe
3839 {
3940 var result = GetStringList ( null , param ) ;
40- if ( result == ( byte * ) 0 )
41- {
42- return new List < string > ( ) ;
43- }
41+ if ( result is null ) return Enumerable . Empty < string > ( ) ;
4442
4543 var strings = new List < string > ( ) ;
46-
44+
4745 var currentPos = result ;
48- while ( true )
46+ while ( * currentPos != ' \0 ' )
4947 {
50- var currentString = Marshal . PtrToStringAnsi ( ( nint ) currentPos ) ;
51- if ( string . IsNullOrEmpty ( currentString ) )
52- {
53- break ;
54- }
48+ var currentLength = ( int ) SilkMarshal . StringLength ( ( nint ) currentPos , NativeStringEncoding . UTF8 ) ;
49+ var currentString = Encoding . UTF8 . GetString ( currentPos , currentLength ) ;
5550
5651 strings . Add ( currentString ) ;
57- currentPos += currentString . Length + 1 ;
52+ currentPos += currentLength + 1 ;
5853 }
5954
6055 return strings ;
Original file line number Diff line number Diff line change 33
44using System ;
55using System . Collections . Generic ;
6- using System . Runtime . InteropServices ;
6+ using System . Linq ;
7+ using System . Text ;
78using Silk . NET . Core . Attributes ;
89using Silk . NET . Core . Contexts ;
910using Silk . NET . Core . Native ;
@@ -36,24 +37,18 @@ public IEnumerable<string> GetStringList(GetEnumerationContextStringList param)
3637 unsafe
3738 {
3839 var result = GetStringList ( null , param ) ;
39- if ( result == ( byte * ) 0 )
40- {
41- return new List < string > ( ) ;
42- }
40+ if ( result is null ) return Enumerable . Empty < string > ( ) ;
4341
4442 var strings = new List < string > ( ) ;
4543
4644 var currentPos = result ;
47- while ( true )
45+ while ( * currentPos != ' \0 ' )
4846 {
49- var currentString = Marshal . PtrToStringAnsi ( ( nint ) currentPos ) ;
50- if ( string . IsNullOrEmpty ( currentString ) )
51- {
52- break ;
53- }
47+ var currentLength = ( int ) SilkMarshal . StringLength ( ( nint ) currentPos , NativeStringEncoding . UTF8 ) ;
48+ var currentString = Encoding . UTF8 . GetString ( currentPos , currentLength ) ;
5449
5550 strings . Add ( currentString ) ;
56- currentPos += currentString . Length + 1 ;
51+ currentPos += currentLength + 1 ;
5752 }
5853
5954 return strings ;
You can’t perform that action at this time.
0 commit comments