Skip to content

Commit

Permalink
slight code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RepellantMold committed Mar 27, 2024
1 parent d36ae7e commit e491c72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ cmake_minimum_required(VERSION 3.0)
project(DumbSThreeMHeaderEditor)

set(CMAKE_C_STANDARD 90)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(DumbSThreeMHeaderEditor main.c)
add_executable(DumbSThreeMHeaderEditor main.c)
# https://stackoverflow.com/a/50882216
if(MSVC)
target_compile_options(DumbSThreeMHeaderEditor PRIVATE /W4 /WX)
else()
target_compile_options(DumbSThreeMHeaderEditor PRIVATE -Wall -Wextra -Wpedantic -Werror -march=native)
endif()
12 changes: 2 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
int
main(int argc, char* argv[]) {

char* header;
unsigned char header[96] = {0};
unsigned char flaggos, stereotoggle, i = 0;
unsigned short trackerinfo = 0;

Expand All @@ -25,12 +25,6 @@ main(int argc, char* argv[]) {
return 1;
}

header = (char*)calloc(96, sizeof(char));
if (header == NULL) {
puts("Failed to allocate memory!");
return 2;
}

fread(header, sizeof(char), 96, s3m);

if (header[44] != 'S' || header[45] != 'C' || header[46] != 'R' || header[47] != 'M') {
Expand Down Expand Up @@ -120,11 +114,9 @@ main(int argc, char* argv[]) {
scanf("%hhu", &header[64 + i]);
}

fseek(s3m, 0, SEEK_SET);
rewind(s3m);
fwrite(header, sizeof(char), 96, s3m);

free(header);

fclose(s3m);

puts("Done!");
Expand Down

0 comments on commit e491c72

Please sign in to comment.