File tree Expand file tree Collapse file tree 4 files changed +8
-18
lines changed
Expand file tree Collapse file tree 4 files changed +8
-18
lines changed Original file line number Diff line number Diff line change 66
77#ifdef _WIN32
88#include <windows.h>
9+ #define _CRT_SECURE_NO_WARNINGS
910#endif
1011
1112// convert pokémon ranger 2 mes format (sequential blocks) to json
@@ -30,7 +31,7 @@ int mes_to_json(const char *input, const char *output) {
3031 off += 4 ;
3132 if (off + blk > size ) goto error_strings ;
3233
33- strings [i ] = xstrdup ((char * )(buf + off ));
34+ strings [i ] = strdup ((char * )(buf + off ));
3435 if (!strings [i ]) goto error_strings ;
3536
3637 off += blk ;
@@ -135,12 +136,12 @@ int main(int argc, char **argv) {
135136 }
136137
137138 if (strcmp (argv [1 ], "--to-json" ) == 0 ) { // mes to json
138- output = outarg ? xstrdup (outarg ) : make_output_path (input , ".json" );
139+ output = outarg ? strdup (outarg ) : make_output_path (input , ".json" );
139140 if (!output ) return EXIT_FAILURE ;
140141 result = mes_to_json (input , output );
141142
142143 } else if (strcmp (argv [1 ], "--to-mes" ) == 0 ) { // json to mes
143- output = outarg ? xstrdup (outarg ) : make_output_path (input , ".mes" );
144+ output = outarg ? strdup (outarg ) : make_output_path (input , ".mes" );
144145 if (!output ) return EXIT_FAILURE ;
145146 result = json_to_mes (input , output );
146147
Original file line number Diff line number Diff line change 66
77#ifdef _WIN32
88#include <windows.h>
9+ #define _CRT_SECURE_NO_WARNINGS
910#endif
1011
1112// convert pokémon ranger 3 mes format (offset table) to json
@@ -27,7 +28,7 @@ int mes_to_json(const char *input, const char *output) {
2728 uint32_t off = read_u32_le (buf + 8 + i * 4 );
2829 if (off >= size ) goto error_strings ;
2930
30- strings [i ] = xstrdup ((char * )(buf + off ));
31+ strings [i ] = strdup ((char * )(buf + off ));
3132 if (!strings [i ]) goto error_strings ;
3233 }
3334
@@ -137,12 +138,12 @@ int main(int argc, char **argv) {
137138 }
138139
139140 if (strcmp (argv [1 ], "--to-json" ) == 0 ) { // mes to json
140- output = outarg ? xstrdup (outarg ) : make_output_path (input , ".json" );
141+ output = outarg ? strdup (outarg ) : make_output_path (input , ".json" );
141142 if (!output ) return EXIT_FAILURE ;
142143 result = mes_to_json (input , output );
143144
144145 } else if (strcmp (argv [1 ], "--to-mes" ) == 0 ) { // json to mes
145- output = outarg ? xstrdup (outarg ) : make_output_path (input , ".mes" );
146+ output = outarg ? strdup (outarg ) : make_output_path (input , ".mes" );
146147 if (!output ) return EXIT_FAILURE ;
147148 result = json_to_mes (input , output );
148149
Original file line number Diff line number Diff line change @@ -33,15 +33,6 @@ int file_exists(const char *path) {
3333 return stat (path , & st ) == 0 ;
3434}
3535
36- // strdup implementation
37- char * xstrdup (const char * s ) {
38- if (!s ) return NULL ;
39- size_t len = strlen (s ) + 1 ;
40- char * p = malloc (len );
41- if (p ) memcpy (p , s , len );
42- return p ;
43- }
44-
4536// read entire file into memory
4637unsigned char * read_file (const char * path , size_t * out_size ) {
4738 FILE * f = NULL ;
Original file line number Diff line number Diff line change @@ -13,9 +13,6 @@ void write_u32_le(unsigned char *b, uint32_t v);
1313// padding to 4-byte boundary
1414uint32_t pad4 (uint32_t n );
1515
16- // strdup implementation
17- char * xstrdup (const char * s );
18-
1916// file helpers
2017int file_exists (const char * path );
2118int is_json_file (const unsigned char * buf , size_t size );
You can’t perform that action at this time.
0 commit comments