twn_util.c: add file_read()
This commit is contained in:
@ -754,6 +754,11 @@ static bool try_mounting_root_pack(char *path) {
|
||||
}
|
||||
|
||||
|
||||
static void garbage_collect(void) {
|
||||
file_read_garbage_collect();
|
||||
}
|
||||
|
||||
|
||||
int enter_loop(int argc, char **argv) {
|
||||
profile_start("startup");
|
||||
|
||||
@ -866,6 +871,7 @@ int enter_loop(int argc, char **argv) {
|
||||
/* dispatch all filewatch driven events, such as game object and asset pack reload */
|
||||
filewatch_poll();
|
||||
main_loop();
|
||||
garbage_collect();
|
||||
}
|
||||
|
||||
if (ctx.game.debug)
|
||||
|
@ -154,6 +154,24 @@ char *file_to_str(const char *path) {
|
||||
return str_out;
|
||||
}
|
||||
|
||||
static char **read_files;
|
||||
|
||||
char const *file_read(char const *file) {
|
||||
char *s = file_to_str(file);
|
||||
|
||||
if (s) arrpush(read_files, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void file_read_garbage_collect(void) {
|
||||
for (size_t i = 0; i < arrlenu(read_files); ++i)
|
||||
SDL_free(read_files[i]);
|
||||
arrfree(read_files);
|
||||
read_files = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool file_exists(const char *path) {
|
||||
return PHYSFS_exists(path);
|
||||
|
@ -29,6 +29,8 @@ char *expand_asterisk(const char *mask, const char *to);
|
||||
|
||||
void profile_list_stats(void);
|
||||
|
||||
void file_read_garbage_collect(void);
|
||||
|
||||
/* http://www.azillionmonkeys.com/qed/sqroot.html */
|
||||
static inline float fast_sqrt(float x)
|
||||
{
|
||||
|
Reference in New Issue
Block a user