11#include "utils.h"
2+ #include <stddef.h>
23#include <stdlib.h>
34#include <string.h>
45
56char * urlDecode (char * raw )
67{
7- char * result = malloc (strlen (raw ) + 1 ); // URLEncoded string will NEVER be longer decoded
8+ char * result = ( char * ) malloc (strlen (raw ) + 1 ); // URLEncoded string will NEVER be longer decoded
89 int currentFilepathLen = 0 ;
910
1011 for (size_t i = 0 ; i < strlen (raw ); i ++ ) {
@@ -19,6 +20,13 @@ char* urlDecode(char* raw)
1920 return result ;
2021}
2122
23+ char * buildCommand (const char * command , const char * sub )
24+ {
25+ char * builtCommand = (char * ) malloc (strlen (command ) + strlen (sub ) + 1 );
26+ sprintf (builtCommand , command , sub );
27+ return builtCommand ;
28+ }
29+
2230void recursiveDelete (char * path )
2331{
2432 DIR * dir = opendir (path );
@@ -29,7 +37,7 @@ void recursiveDelete(char* path)
2937 {
3038 continue ;
3139 }
32- char * itemPath = malloc (strlen (path ) + 1 + strlen (item -> d_name ) + 1 );
40+ char * itemPath = ( char * ) malloc (strlen (path ) + 1 + strlen (item -> d_name ) + 1 );
3341 sprintf (itemPath , "%s/%s" , path , item -> d_name );
3442 if (item -> d_type == DT_DIR )
3543 {
@@ -42,13 +50,6 @@ void recursiveDelete(char* path)
4250 closedir (dir );
4351}
4452
45- char * buildCommand (char * command , char * sub )
46- {
47- char * builtCommand = malloc (strlen (command ) + strlen (sub ) + 1 );
48- sprintf (builtCommand , command , sub );
49- return builtCommand ;
50- }
51-
5253void freeScriptHeader (struct ScriptHeader * header )
5354{
5455 free (header -> name );
@@ -58,7 +59,7 @@ void freeScriptHeader(struct ScriptHeader* header)
5859 header -> name = NULL ;
5960 header -> author = NULL ;
6061 header -> icon = NULL ;
61- };
62+ }
6263
6364void readScriptHeader (FILE * file , struct ScriptHeader * header )
6465{
@@ -68,12 +69,12 @@ void readScriptHeader(FILE* file, struct ScriptHeader* header)
6869 header -> useFBInk = true;
6970 header -> useHooks = false;
7071
71- int bufferSize = 1024 ;
72- char * buffer = malloc (bufferSize );
72+ size_t bufferSize = 1024 ;
73+ char * buffer = ( char * ) malloc (bufferSize );
7374 fseek (file , 0 , SEEK_SET );
7475 for (int i = 0 ; i < 6 ; i ++ ) {
7576 buffer [0 ] = '\0' ;
76- int lineLength = 0 ;
77+ size_t lineLength = 0 ;
7778 int c ;
7879 while ((c = fgetc (file )) != EOF )
7980 {
@@ -84,15 +85,15 @@ void readScriptHeader(FILE* file, struct ScriptHeader* header)
8485
8586 if (lineLength + 2 >= bufferSize )
8687 {
87- buffer = realloc (buffer , bufferSize += (lineLength + 2 ));
88+ buffer = ( char * ) realloc (buffer , bufferSize += (lineLength + 2 ));
8889 if (buffer == NULL )
8990 {
9091 printf ("FATAL - FAILED TO REALLOC BUFFER!!!\n" );
9192 return ; //@TODO: We don't really have a good way of dealing with this
9293 }
9394 }
9495
95- buffer [lineLength ++ ] = c ;
96+ buffer [lineLength ++ ] = ( char ) c ;
9697 }
9798 buffer [lineLength ] = '\0' ;
9899
@@ -124,4 +125,4 @@ void readScriptHeader(FILE* file, struct ScriptHeader* header)
124125 }
125126 }
126127 free (buffer );
127- };
128+ }
0 commit comments