mirror of
https://github.com/ErnyTech/Open-USB-Extreme
synced 2025-01-15 04:57:33 +01:00
toD: Fix issue with castArray and remove pointer in ouePointHeaders
This commit is contained in:
parent
28d6ee7d8f
commit
192384a3c3
@ -86,7 +86,7 @@ enum SCECdvdMediaType
|
||||
extern (D) int isOue(const(void)[] headers);
|
||||
extern (D) UsbExtremeVersion getVersion(uint8_t usbExtremeVersion);
|
||||
extern (D) int oueNumHeaders(ref int num_headers, const(void)[] headers);
|
||||
extern (D) int ouePointHeaders(ref const(usb_extreme_base)* headers, const(void)[] raw_headers);
|
||||
extern (D) int ouePointHeaders(ref const(usb_extreme_base)[] headers, const(void)[] raw_headers);
|
||||
extern (D) int oueHeadersVersion(ref UsbExtremeVersion oueVersion, const(void)[] headers);
|
||||
extern (D) int oueReadHeaders(ref usb_extreme_headers headers, const(void)[] raw_headers);
|
||||
extern (D) int oueRead(usb_extreme_filestat[] filestat, const(usb_extreme_headers) headers);
|
||||
|
@ -15,7 +15,9 @@ extern(C) int oue_num_headers(int *num_headers, const(void) *headers, size_t hea
|
||||
}
|
||||
|
||||
extern(C) int oue_point_headers(const(usb_extreme_base)** headers, const(void)* raw_headers, size_t headerslen) {
|
||||
return ouePointHeaders(*headers, raw_headers[0..headerslen]);
|
||||
auto len = headerslen / usb_extreme_base.sizeof;
|
||||
const(usb_extreme_base)[] headersArr = (*headers)[0..len];
|
||||
return ouePointHeaders(headersArr, raw_headers[0..headerslen]);
|
||||
}
|
||||
|
||||
extern(C) int oue_version(UsbExtremeVersion* oueVersion, const(void) *headers, size_t headerslen) {
|
||||
|
@ -119,16 +119,14 @@ extern(D) int oueNumHeaders(ref int num_headers, const(void)[] headers) {
|
||||
return headers_nlen;
|
||||
}
|
||||
|
||||
extern(D) int ouePointHeaders(ref const(usb_extreme_base)* headers, const(void)[] raw_headers) {
|
||||
import core.stdc.stdio;
|
||||
extern(D) int ouePointHeaders(ref const(usb_extreme_base)[] headers, const(void)[] raw_headers) {
|
||||
int headers_nlen;
|
||||
|
||||
if (oueNumHeaders(headers_nlen, raw_headers) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto headersArr = castArray!(const(usb_extreme_base))(raw_headers)[];
|
||||
headers = headersArr.ptr;
|
||||
headers = castArray!(const(usb_extreme_base))(raw_headers)[];
|
||||
return headers_nlen;
|
||||
}
|
||||
|
||||
@ -218,5 +216,5 @@ extern(D) int oueRead(usb_extreme_filestat[] filestat, const(usb_extreme_headers
|
||||
private R[] castArray(R, T) (T[] array) { // Workaround for https://issues.dlang.org/show_bug.cgi?id=20088
|
||||
auto ptr = array.ptr;
|
||||
auto castPtr = cast(R*) ptr;
|
||||
return castPtr[0..(array.length / R.sizeof)];
|
||||
return castPtr[0..((array.length * T.sizeof) / R.sizeof)];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user