Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Oct 3, 2024
1 parent dbea584 commit 7e8a482
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions src/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int remove_file(const char* const filename) {
return -1;
}

wfilename = malloc(prefixs + (size_t) wfilenames);
wfilename = malloc((prefixs + (size_t) wfilenames) * sizeof(*wfilename));

if (prefixs > 0) {
wcscpy(wfilename, WIN10_LONG_PATH_PREFIX);
Expand Down Expand Up @@ -275,7 +275,7 @@ static int remove_empty_directory(const char* const directory) {
return -1;
}

wdirectory = malloc(prefixs + (size_t) wdirectorys);
wdirectory = malloc((prefixs + (size_t) wdirectorys) * sizeof(*wdirectory));

if (wdirectory == NULL) {
return -1;
Expand Down Expand Up @@ -415,7 +415,7 @@ int directory_exists(const char* const directory) {
return -1;
}

wdirectory = malloc(prefixs + (size_t) wdirectorys);
wdirectory = malloc((prefixs + (size_t) wdirectorys) * sizeof(*wdirectory));

if (wdirectory == NULL) {
return -1;
Expand Down Expand Up @@ -486,7 +486,7 @@ int file_exists(const char* const filename) {
return -1;
}

wfilename = malloc(prefixs + (size_t) wfilenames);
wfilename = malloc((prefixs + (size_t) wfilenames) * sizeof(*wfilename));

if (wfilename == NULL) {
return -1;
Expand Down Expand Up @@ -555,12 +555,12 @@ static int raw_create_dir(const char* const directory) {
const size_t prefixs = isabsolute(directory) ? wcslen(WIN10_LONG_PATH_PREFIX) : 0;

const int wdirectorys = MultiByteToWideChar(CP_UTF8, 0, directory, -1, NULL, 0);
printf("%i %s\n", wdirectorys, directory);

if (wdirectorys == 0) {
return -1;
}

wdirectory = malloc(prefixs + (size_t) wdirectorys);
wdirectory = malloc((prefixs + (size_t) wdirectorys) * sizeof(*wdirectory));

if (wdirectory == NULL) {
return -1;
Expand Down Expand Up @@ -691,7 +691,7 @@ int copy_file(const char* const source, const char* const destination) {
return -1;
}

wsource = malloc(prefixs + (size_t) wfilenames);
wsource = malloc((prefixs + (size_t) wfilenames) * sizeof(*wsource));

if (prefixs > 0) {
wcscpy(wsource, WIN10_LONG_PATH_PREFIX);
Expand All @@ -711,7 +711,7 @@ int copy_file(const char* const source, const char* const destination) {
return -1;
}

wdestination = malloc(prefixs + (size_t) wfilenames);
wdestination = malloc((prefixs + (size_t) wfilenames) * sizeof(*wdestination));

if (prefixs > 0) {
wcscpy(wdestination, WIN10_LONG_PATH_PREFIX);
Expand Down Expand Up @@ -831,7 +831,7 @@ int move_file(const char* const source, const char* const destination) {
return -1;
}

wsource = malloc(prefixs + (size_t) wfilenames);
wsource = malloc((prefixs + (size_t) wfilenames) * sizeof(*wsource));

if (prefixs > 0) {
wcscpy(wsource, WIN10_LONG_PATH_PREFIX);
Expand All @@ -851,7 +851,7 @@ int move_file(const char* const source, const char* const destination) {
return -1;
}

wdestination = malloc(prefixs + (size_t) wfilenames);
wdestination = malloc((prefixs + (size_t) wfilenames) * sizeof(*wdestination));

if (prefixs > 0) {
wcscpy(wdestination, WIN10_LONG_PATH_PREFIX);
Expand Down Expand Up @@ -926,7 +926,7 @@ char* get_app_filename(void) {

filenames++;

wfilename = malloc((size_t) filenames);
wfilename = malloc(((size_t) filenames) * sizeof(*wfilename));

if (wfilename == NULL) {
return NULL;
Expand Down Expand Up @@ -1198,7 +1198,7 @@ char* expand_filename(const char* const filename) {
return NULL;
}

wfilename = malloc(prefixs + (size_t) wfilenames);
wfilename = malloc((prefixs + (size_t) wfilenames) * sizeof(*wfilename));

if (wfilename == NULL) {
return NULL;
Expand All @@ -1220,7 +1220,7 @@ char* expand_filename(const char* const filename) {
return NULL;
}

wexpanded_filename = malloc((size_t) size);
wexpanded_filename = malloc(((size_t) size) * sizeof(*wexpanded_filename));

if (wexpanded_filename == NULL) {
free(wfilename);
Expand Down
2 changes: 1 addition & 1 deletion src/fstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct FStream* fstream_open(const char* const filename, const enum FStreamMode
return NULL;
}

wfilename = malloc(prefixs + (size_t) wfilenames+90);
wfilename = malloc((prefixs + (size_t) wfilenames) * sizeof(*wfilename));

if (prefixs > 0) {
wcscpy(wfilename, WIN10_LONG_PATH_PREFIX);
Expand Down
2 changes: 1 addition & 1 deletion src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int execute_shell_command(const char* const command) {
return -1;
}

wcommand = malloc((size_t) wcommands);
wcommand = malloc(((size_t) wcommands) * sizeof(*wcommand));

if (wcommand == NULL) {
return -1;
Expand Down
6 changes: 3 additions & 3 deletions src/walkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int walkdir_init(struct WalkDir* const walkdir, const char* const directory) {
return -1;
}

wpathsep = malloc((size_t) wpathseps);
wpathsep = malloc(((size_t) wpathseps) * sizeof(*wpathsep));

if (wpathsep == NULL) {
return -1;
Expand All @@ -72,7 +72,7 @@ int walkdir_init(struct WalkDir* const walkdir, const char* const directory) {
return -1;
}

wasterisk = malloc((size_t) wasterisks);
wasterisk = malloc(((size_t) wasterisks) * sizeof(*wasterisk));

if (wasterisk == NULL) {
free(wpathsep);
Expand All @@ -85,7 +85,7 @@ int walkdir_init(struct WalkDir* const walkdir, const char* const directory) {
return -1;
}

wpattern = malloc(prefixs + (size_t) wpatterns + wcslen(wpathsep) + wcslen(wasterisk));
wpattern = malloc((prefixs + (size_t) wpatterns + wcslen(wpathsep) + wcslen(wasterisk)) * sizeof(*wpattern));

if (wpattern == NULL) {
free(wpathsep);
Expand Down
4 changes: 2 additions & 2 deletions src/wio.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int wio_printf(const char* const format, ...) {
goto end;
}

wvalue = malloc((size_t) wsize);
wvalue = malloc(((size_t) wsize) * sizeof(*wvalue));

if (wvalue == NULL) {
wsize = -1;
Expand Down Expand Up @@ -108,7 +108,7 @@ int wio_fprintf(FILE* const stream, const char* const format, ...) {
goto end;
}

wvalue = malloc((size_t) wsize);
wvalue = malloc(((size_t) wsize) * sizeof(*wvalue));

if (wvalue == NULL) {
wsize = -1;
Expand Down

0 comments on commit 7e8a482

Please sign in to comment.