Skip to content

Commit 72d233a

Browse files
committed
Resync
1 parent 3d86e1c commit 72d233a

5 files changed

Lines changed: 49 additions & 16 deletions

File tree

file/config_file.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ static int config_sort_compare_func(struct config_entry_list *a,
6464
{
6565
if (a && b)
6666
{
67-
if (a->key && b->key)
68-
return strcasecmp(a->key, b->key);
69-
else if (a->key)
67+
if (a->key)
68+
{
69+
if (b->key)
70+
return strcasecmp(a->key, b->key);
7071
return 1;
72+
}
7173
else if (b->key)
7274
return -1;
7375
}
@@ -1179,20 +1181,23 @@ void config_file_dump_orbis(config_file_t *conf, int fd)
11791181
while (includes)
11801182
{
11811183
char cad[256];
1182-
sprintf(cad,"#include %s\n", includes->path);
1184+
snprintf(cad, sizeof(cad),
1185+
"#include %s\n", includes->path);
11831186
orbisWrite(fd, cad, strlen(cad));
11841187
includes = includes->next;
11851188
}
11861189

1187-
list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func);
1190+
list = merge_sort_linked_list((struct config_entry_list*)
1191+
conf->entries, config_sort_compare_func);
11881192
conf->entries = list;
11891193

11901194
while (list)
11911195
{
11921196
if (!list->readonly && list->key)
11931197
{
11941198
char newlist[256];
1195-
sprintf(newlist,"%s = %s\n", list->key, list->value);
1199+
snprintf(newlist, sizeof(newlist),
1200+
"%s = %s\n", list->key, list->value);
11961201
orbisWrite(fd, newlist, strlen(newlist));
11971202
}
11981203
list = list->next;

file/file_path.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,17 +1280,15 @@ void fill_pathname_home_dir(char *s, size_t len)
12801280

12811281
bool is_path_accessible_using_standard_io(const char *path)
12821282
{
1283-
bool result = true;
12841283
#ifdef __WINRT__
1285-
size_t path_sizeof = PATH_MAX_LENGTH * sizeof(char);
1286-
char *relative_path_abbrev = (char*)malloc(path_sizeof);
1287-
fill_pathname_abbreviate_special(relative_path_abbrev, path, path_sizeof);
1288-
1289-
result = (strlen(relative_path_abbrev) >= 2 )
1290-
&& (relative_path_abbrev[0] == ':' || relative_path_abbrev[0] == '~')
1284+
char relative_path_abbrev[PATH_MAX_LENGTH];
1285+
fill_pathname_abbreviate_special(relative_path_abbrev,
1286+
path, sizeof(relative_path_abbrev));
1287+
return (strlen(relative_path_abbrev) >= 2 )
1288+
&& ( relative_path_abbrev[0] == ':'
1289+
|| relative_path_abbrev[0] == '~')
12911290
&& PATH_CHAR_IS_SLASH(relative_path_abbrev[1]);
1292-
1293-
free(relative_path_abbrev);
1291+
#else
1292+
return true;
12941293
#endif
1295-
return result;
12961294
}

include/file/config_file.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ config_file_t *config_file_new_from_path_to_string(const char *path);
105105
/* Frees config file. */
106106
void config_file_free(config_file_t *conf);
107107

108+
bool config_file_deinitialize(config_file_t *conf);
109+
108110
/* Loads a new config, and appends its data to conf.
109111
* The key-value pairs of the new config file takes priority over the old. */
110112
bool config_append_file(config_file_t *conf, const char *path);

include/lists/dir_list.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define __LIBRETRO_SDK_DIR_LIST_H
2525

2626
#include <retro_common_api.h>
27+
#include <boolean.h>
2728

2829
#include <lists/string_list.h>
2930

@@ -63,6 +64,12 @@ bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
6364
struct string_list *dir_list_new(const char *dir, const char *ext,
6465
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
6566

67+
bool dir_list_initialize(struct string_list *list,
68+
const char *dir,
69+
const char *ext, bool include_dirs,
70+
bool include_hidden, bool include_compressed,
71+
bool recursive);
72+
6673
/**
6774
* dir_list_sort:
6875
* @list : pointer to the directory listing.
@@ -82,6 +89,8 @@ void dir_list_sort(struct string_list *list, bool dir_first);
8289
**/
8390
void dir_list_free(struct string_list *list);
8491

92+
bool dir_list_deinitialize(struct string_list *list);
93+
8594
RETRO_END_DECLS
8695

8796
#endif

lists/dir_list.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ void dir_list_free(struct string_list *list)
8686
string_list_free(list);
8787
}
8888

89+
bool dir_list_deinitialize(struct string_list *list)
90+
{
91+
if (!list)
92+
return false;
93+
return string_list_deinitialize(list);
94+
}
95+
8996
/**
9097
* dir_list_read:
9198
* @dir : directory path.
@@ -249,3 +256,15 @@ struct string_list *dir_list_new(const char *dir,
249256

250257
return list;
251258
}
259+
260+
bool dir_list_initialize(struct string_list *list,
261+
const char *dir,
262+
const char *ext, bool include_dirs,
263+
bool include_hidden, bool include_compressed,
264+
bool recursive)
265+
{
266+
if (!list)
267+
return NULL;
268+
return dir_list_append(list, dir, ext, include_dirs,
269+
include_hidden, include_compressed, recursive);
270+
}

0 commit comments

Comments
 (0)