Skip to content

Commit 5e28f36

Browse files
committed
resync
1 parent 94cb776 commit 5e28f36

11 files changed

Lines changed: 230 additions & 99 deletions

File tree

include/libretro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,7 @@ struct retro_input_descriptor
26722672
struct retro_system_info
26732673
{
26742674
/* All pointers are owned by libretro implementation, and pointers must
2675-
* remain valid until retro_deinit() is called. */
2675+
* remain valid until it is unloaded. */
26762676

26772677
const char *library_name; /* Descriptive name of library. Should not
26782678
* contain any version numbers, etc. */

include/lists/file_list.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ void *file_list_get_actiondata_at_offset(const file_list_t *list,
7070
*/
7171
void file_list_free(file_list_t *list);
7272

73+
bool file_list_deinitialize(file_list_t *list);
74+
75+
bool file_list_initialize(file_list_t *list);
76+
7377
/**
7478
* @brief makes the list big enough to contain at least nitems
7579
*

include/lists/string_list.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ struct string_list *string_split(const char *str, const char *delim);
101101
*/
102102
struct string_list *string_separate(char *str, const char *delim);
103103

104+
bool string_list_deinitialize(struct string_list *list);
105+
106+
bool string_list_initialize(struct string_list *list);
107+
104108
/**
105109
* string_list_new:
106110
*

include/queues/fifo_queue.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <retro_common_api.h>
3131
#include <retro_inline.h>
32+
#include <boolean.h>
3233

3334
RETRO_BEGIN_DECLS
3435

@@ -54,14 +55,7 @@ void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size);
5455

5556
void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size);
5657

57-
static INLINE void fifo_free(fifo_buffer_t *buffer)
58-
{
59-
if (!buffer)
60-
return;
61-
62-
free(buffer->buffer);
63-
free(buffer);
64-
}
58+
void fifo_free(fifo_buffer_t *buffer);
6559

6660
#define FIFO_READ_AVAIL(buffer) (((buffer)->end + (((buffer)->end < (buffer)->first) ? (buffer)->size : 0)) - (buffer)->first)
6761

include/queues/message_queue.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,23 @@ enum message_queue_category
4343
MESSAGE_QUEUE_CATEGORY_SUCCESS
4444
};
4545

46-
typedef struct msg_queue msg_queue_t;
46+
typedef struct queue_elem
47+
{
48+
char *msg;
49+
char *title;
50+
unsigned duration;
51+
unsigned prio;
52+
enum message_queue_icon icon;
53+
enum message_queue_category category;
54+
} queue_elem_t;
55+
56+
typedef struct msg_queue
57+
{
58+
char *tmp_msg;
59+
queue_elem_t **elems;
60+
size_t ptr;
61+
size_t size;
62+
} msg_queue_t;
4763

4864
typedef struct
4965
{
@@ -66,6 +82,8 @@ typedef struct
6682
**/
6783
msg_queue_t *msg_queue_new(size_t size);
6884

85+
bool msg_queue_initialize(msg_queue_t *queue, size_t size);
86+
6987
/**
7088
* msg_queue_push:
7189
* @queue : pointer to queue object
@@ -131,6 +149,8 @@ void msg_queue_clear(msg_queue_t *queue);
131149
**/
132150
void msg_queue_free(msg_queue_t *queue);
133151

152+
bool msg_queue_deinitialize(msg_queue_t *queue);
153+
134154
RETRO_END_DECLS
135155

136156
#endif

lists/dir_list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ struct string_list *dir_list_new(const char *dir,
235235
bool include_hidden, bool include_compressed,
236236
bool recursive)
237237
{
238-
struct string_list *list = NULL;
238+
struct string_list *list = string_list_new();
239239

240-
if (!(list = string_list_new()))
240+
if (!list)
241241
return NULL;
242242

243243
if (!dir_list_append(list, dir, ext, include_dirs,

lists/file_list.c

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,44 @@
2929
#include <string/stdstring.h>
3030
#include <compat/strcasestr.h>
3131

32+
static bool file_list_deinitialize_internal(file_list_t *list)
33+
{
34+
size_t i;
35+
for (i = 0; i < list->size; i++)
36+
{
37+
file_list_free_userdata(list, i);
38+
file_list_free_actiondata(list, i);
39+
40+
if (list->list[i].path)
41+
free(list->list[i].path);
42+
list->list[i].path = NULL;
43+
44+
if (list->list[i].label)
45+
free(list->list[i].label);
46+
list->list[i].label = NULL;
47+
48+
if (list->list[i].alt)
49+
free(list->list[i].alt);
50+
list->list[i].alt = NULL;
51+
}
52+
if (list->list)
53+
free(list->list);
54+
list->list = NULL;
55+
return true;
56+
}
57+
58+
bool file_list_initialize(file_list_t *list)
59+
{
60+
if (!list)
61+
return false;
62+
63+
list->list = NULL;
64+
list->capacity = 0;
65+
list->size = 0;
66+
67+
return true;
68+
}
69+
3270
bool file_list_reserve(file_list_t *list, size_t nitems)
3371
{
3472
const size_t item_size = sizeof(struct item_file);
@@ -182,34 +220,23 @@ void file_list_pop(file_list_t *list, size_t *directory_ptr)
182220

183221
void file_list_free(file_list_t *list)
184222
{
185-
size_t i;
186-
187223
if (!list)
188224
return;
189-
190-
for (i = 0; i < list->size; i++)
191-
{
192-
file_list_free_userdata(list, i);
193-
file_list_free_actiondata(list, i);
194-
195-
if (list->list[i].path)
196-
free(list->list[i].path);
197-
list->list[i].path = NULL;
198-
199-
if (list->list[i].label)
200-
free(list->list[i].label);
201-
list->list[i].label = NULL;
202-
203-
if (list->list[i].alt)
204-
free(list->list[i].alt);
205-
list->list[i].alt = NULL;
206-
}
207-
if (list->list)
208-
free(list->list);
209-
list->list = NULL;
225+
file_list_deinitialize_internal(list);
210226
free(list);
211227
}
212228

229+
bool file_list_deinitialize(file_list_t *list)
230+
{
231+
if (!list)
232+
return false;
233+
if (!file_list_deinitialize_internal(list))
234+
return false;
235+
list->capacity = 0;
236+
list->size = 0;
237+
return true;
238+
}
239+
213240
void file_list_clear(file_list_t *list)
214241
{
215242
size_t i;

lists/string_list.c

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,14 @@
2929
#include <compat/posix_string.h>
3030
#include <string/stdstring.h>
3131

32-
/**
33-
* string_list_free
34-
* @list : pointer to string list object
35-
*
36-
* Frees a string list.
37-
*/
38-
void string_list_free(struct string_list *list)
32+
static bool string_list_deinitialize_internal(struct string_list *list)
3933
{
40-
size_t i;
4134
if (!list)
42-
return;
35+
return false;
4336

4437
if (list->elems)
4538
{
39+
unsigned i;
4640
for (i = 0; i < list->size; i++)
4741
{
4842
if (list->elems[i].data)
@@ -57,7 +51,8 @@ void string_list_free(struct string_list *list)
5751
}
5852

5953
list->elems = NULL;
60-
free(list);
54+
55+
return true;
6156
}
6257

6358
/**
@@ -85,6 +80,38 @@ static bool string_list_capacity(struct string_list *list, size_t cap)
8580
return true;
8681
}
8782

83+
static bool string_list_initialize_internal(struct string_list *list)
84+
{
85+
list->elems = NULL;
86+
list->size = 0;
87+
list->cap = 0;
88+
89+
return string_list_capacity(list, 32);
90+
}
91+
92+
/**
93+
* string_list_free
94+
* @list : pointer to string list object
95+
*
96+
* Frees a string list.
97+
*/
98+
void string_list_free(struct string_list *list)
99+
{
100+
if (!list)
101+
return;
102+
103+
string_list_deinitialize_internal(list);
104+
105+
free(list);
106+
}
107+
108+
bool string_list_deinitialize(struct string_list *list)
109+
{
110+
if (!list)
111+
return false;
112+
return string_list_deinitialize_internal(list);
113+
}
114+
88115
/**
89116
* string_list_new:
90117
*
@@ -100,11 +127,7 @@ struct string_list *string_list_new(void)
100127
if (!list)
101128
return NULL;
102129

103-
list->elems = NULL;
104-
list->size = 0;
105-
list->cap = 0;
106-
107-
if (!string_list_capacity(list, 32))
130+
if (!string_list_initialize_internal(list))
108131
{
109132
string_list_free(list);
110133
return NULL;
@@ -113,6 +136,18 @@ struct string_list *string_list_new(void)
113136
return list;
114137
}
115138

139+
bool string_list_initialize(struct string_list *list)
140+
{
141+
if (!list)
142+
return false;
143+
if (!string_list_initialize_internal(list))
144+
{
145+
string_list_free(list);
146+
return false;
147+
}
148+
return true;
149+
}
150+
116151
/**
117152
* string_list_append:
118153
* @list : pointer to string list

queues/fifo_queue.c

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,71 @@
2323
#include <stdlib.h>
2424
#include <string.h>
2525

26+
#include <retro_common_api.h>
27+
#include <retro_inline.h>
28+
#include <boolean.h>
29+
2630
#include <queues/fifo_queue.h>
2731

28-
fifo_buffer_t *fifo_new(size_t size)
32+
static bool fifo_initialize_internal(fifo_buffer_t *buf, size_t size)
2933
{
30-
uint8_t *buffer = NULL;
31-
fifo_buffer_t *buf = (fifo_buffer_t*)malloc(sizeof(*buf));
34+
uint8_t *buffer = (uint8_t*)calloc(1, size + 1);
3235

33-
if (!buf)
34-
return NULL;
36+
if (!buffer)
37+
return false;
3538

39+
buf->buffer = buffer;
40+
buf->size = size + 1;
3641
buf->first = 0;
3742
buf->end = 0;
38-
buffer = (uint8_t*)calloc(1, size + 1);
3943

44+
return true;
45+
}
46+
47+
bool fifo_initialize(fifo_buffer_t *buf, size_t size)
48+
{
49+
if (!buf)
50+
return false;
51+
return fifo_initialize_internal(buf, size);
52+
}
53+
54+
void fifo_free(fifo_buffer_t *buffer)
55+
{
56+
if (!buffer)
57+
return;
58+
59+
free(buffer->buffer);
60+
free(buffer);
61+
}
62+
63+
bool fifo_deinitialize(fifo_buffer_t *buffer)
64+
{
4065
if (!buffer)
66+
return false;
67+
68+
if (buffer->buffer)
69+
free(buffer->buffer);
70+
buffer->buffer = NULL;
71+
buffer->size = 0;
72+
buffer->first = 0;
73+
buffer->end = 0;
74+
75+
return true;
76+
}
77+
78+
fifo_buffer_t *fifo_new(size_t size)
79+
{
80+
fifo_buffer_t *buf = (fifo_buffer_t*)malloc(sizeof(*buf));
81+
82+
if (!buf)
83+
return NULL;
84+
85+
if (!fifo_initialize_internal(buf, size))
4186
{
4287
free(buf);
4388
return NULL;
4489
}
4590

46-
buf->buffer = buffer;
47-
buf->size = size + 1;
48-
4991
return buf;
5092
}
5193

0 commit comments

Comments
 (0)