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 3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using System . Runtime . InteropServices ;
6
+ using System . Linq ;
7
+ using System . Text ;
7
8
using Silk . NET . Core . Attributes ;
8
9
using Silk . NET . Core . Contexts ;
9
10
using Silk . NET . Core . Native ;
@@ -36,24 +37,18 @@ public IEnumerable<string> GetStringList(GetEnumerateAllContextStringList param)
36
37
unsafe
37
38
{
38
39
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 > ( ) ;
43
41
44
42
var strings = new List < string > ( ) ;
45
43
46
44
var currentPos = result ;
47
- while ( true )
45
+ while ( * currentPos != ' \0 ' )
48
46
{
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 ) ;
54
49
55
50
strings . Add ( currentString ) ;
56
- currentPos += currentString . Length + 1 ;
51
+ currentPos += currentLength + 1 ;
57
52
}
58
53
59
54
return strings ;
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using System . Runtime . InteropServices ;
6
+ using System . Linq ;
7
+ using System . Text ;
7
8
using Silk . NET . Core . Attributes ;
8
9
using Silk . NET . Core . Contexts ;
9
10
using Silk . NET . Core . Native ;
@@ -37,24 +38,18 @@ public IEnumerable<string> GetStringList(GetCaptureContextStringList param)
37
38
unsafe
38
39
{
39
40
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 > ( ) ;
44
42
45
43
var strings = new List < string > ( ) ;
46
-
44
+
47
45
var currentPos = result ;
48
- while ( true )
46
+ while ( * currentPos != ' \0 ' )
49
47
{
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 ) ;
55
50
56
51
strings . Add ( currentString ) ;
57
- currentPos += currentString . Length + 1 ;
52
+ currentPos += currentLength + 1 ;
58
53
}
59
54
60
55
return strings ;
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using System . Runtime . InteropServices ;
6
+ using System . Linq ;
7
+ using System . Text ;
7
8
using Silk . NET . Core . Attributes ;
8
9
using Silk . NET . Core . Contexts ;
9
10
using Silk . NET . Core . Native ;
@@ -36,24 +37,18 @@ public IEnumerable<string> GetStringList(GetEnumerationContextStringList param)
36
37
unsafe
37
38
{
38
39
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 > ( ) ;
43
41
44
42
var strings = new List < string > ( ) ;
45
43
46
44
var currentPos = result ;
47
- while ( true )
45
+ while ( * currentPos != ' \0 ' )
48
46
{
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 ) ;
54
49
55
50
strings . Add ( currentString ) ;
56
- currentPos += currentString . Length + 1 ;
51
+ currentPos += currentLength + 1 ;
57
52
}
58
53
59
54
return strings ;
You can’t perform that action at this time.
0 commit comments