Oops, double void pointers don't work

This commit is contained in:
shermp
2019-04-10 21:14:49 +12:00
parent a434094923
commit 3130a1814a
3 changed files with 6 additions and 6 deletions

View File

@@ -199,9 +199,9 @@ static VHDError vhd_load_parent(VHDMeta* vhdm, FILE* f, const char* child_filepa
free(u8_rel_path);
#ifdef _WIN32
uint16_t w_filemode[3] = {0x0072, 0x0062, 0x0000}; /* "rb" */
uint16_t *w_abs_path = NULL;
char *w_abs_path = NULL;
vhd_utf_convert(VHD_UTF_16_LE, abs_path, &w_abs_path);
FILE* par_f = _wfopen(w_abs_path, w_filemode);
FILE* par_f = _wfopen((uint16_t*)w_abs_path, w_filemode);
if (par_f) {
vhdm->parent.f = par_f;
}

View File

@@ -8,7 +8,7 @@
#include <error.h>
#endif
int vhd_utf_convert(VHDUtfType toUTF, void* in_str, void** out_str)
int vhd_utf_convert(VHDUtfType toUTF, void* in_str, char** out_str)
{
#ifdef _WIN32
int out_buff_len = 0;
@@ -20,7 +20,7 @@ int vhd_utf_convert(VHDUtfType toUTF, void* in_str, void** out_str)
out_buff_len = MultiByteToWideChar(CP_UTF8, 0, (LPCCH)in_str, -1, NULL, 0);
out_type = sizeof(WCHAR);
}
char *out = (char*)(*out_str);
char *out = *out_str;
out = calloc(out_buff_len, out_type);
if (out == NULL) {
return -1;
@@ -37,7 +37,7 @@ int vhd_utf_convert(VHDUtfType toUTF, void* in_str, void** out_str)
char *in = (char*)in_str;
size_t in_len = (toUTF == VHD_UTF_8) ? (vhd_u16_strlen(in) * sizeof(uint16_t)) : strlen(in);
size_t out_len = (toUTF == VHD_UTF_8) ? ((in_len * 2) + 1) : ((in_len * 4) + 2);
char *out = (char*)(*out_str);
char *out = *out_str;
out = calloc(out_len, sizeof *out);
if (out == NULL) {
return -1;

View File

@@ -11,7 +11,7 @@ typedef enum {
opposite encoding from toUTF
out_str: Pointer to output string pointer. Encoding shall be determined by toUTF, and is null terminated.
It is the callers repsponsibility to free the memory allocated by this function. */
int vhd_utf_convert(VHDUtfType toUTF, void* in_str, void** out_str);
int vhd_utf_convert(VHDUtfType toUTF, void* in_str, char** out_str);
/* Count the number of "characters" in a null terminated UTF-16 string. Not a true character count, as surrogate
pairs are counted as two "characters". Appears to be the Windows definition of a character for filepath
purposes. */