File tree 4 files changed +16
-2
lines changed
4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ void* (*ecs_os_api_calloc_t)(
47
47
size_t num ,
48
48
size_t size );
49
49
50
+ typedef
51
+ char * (* ecs_os_api_strdup_t )(
52
+ const char * str );
50
53
51
54
/* Threads */
52
55
typedef
@@ -147,6 +150,7 @@ typedef struct ecs_os_api_t {
147
150
ecs_os_api_realloc_t realloc ;
148
151
ecs_os_api_calloc_t calloc ;
149
152
ecs_os_api_free_t free ;
153
+ ecs_os_api_strdup_t strdup ;
150
154
151
155
/* Threads */
152
156
ecs_os_api_thread_new_t thread_new ;
@@ -203,6 +207,7 @@ void ecs_os_set_api_defaults(void);
203
207
#define ecs_os_free (ptr ) ecs_os_api.free(ptr);
204
208
#define ecs_os_realloc (ptr , size ) ecs_os_api.realloc(ptr, size)
205
209
#define ecs_os_calloc (num , size ) ecs_os_api.calloc(num, size)
210
+ #define ecs_os_strdup (str ) ecs_os_api.strdup(str)
206
211
207
212
#if defined(_MSC_VER ) || defined(__MINGW32__ )
208
213
#define ecs_os_alloca (type , count ) _alloca(sizeof(type) * (count))
Original file line number Diff line number Diff line change @@ -756,7 +756,7 @@ ecs_entity_t ecs_new_col_system(
756
756
memset (system_data , 0 , sizeof (EcsColSystem ));
757
757
system_data -> base .action = action ;
758
758
system_data -> base .enabled = true;
759
- system_data -> base .signature = strdup (sig );
759
+ system_data -> base .signature = ecs_os_strdup (sig );
760
760
system_data -> base .time_spent = 0 ;
761
761
system_data -> base .columns = ecs_vector_new (& system_column_params , count );
762
762
system_data -> base .invoke_count = 0 ;
Original file line number Diff line number Diff line change @@ -263,6 +263,14 @@ void ecs_os_api_free(void *ptr) {
263
263
free (ptr );
264
264
}
265
265
266
+ static
267
+ char * ecs_os_api_strdup (const char * str ) {
268
+ int len = strlen (str );
269
+ char * result = ecs_os_api_malloc (len + 1 );
270
+ strcpy (result , str );
271
+ return result ;
272
+ }
273
+
266
274
void ecs_os_set_api_defaults (void )
267
275
{
268
276
/* Don't overwrite if already initialized */
@@ -276,6 +284,7 @@ void ecs_os_set_api_defaults(void)
276
284
ecs_os_api .free = ecs_os_api_free ;
277
285
ecs_os_api .realloc = ecs_os_api_realloc ;
278
286
ecs_os_api .calloc = ecs_os_api_calloc ;
287
+ ecs_os_api .strdup = ecs_os_api_strdup ;
279
288
280
289
#ifdef __BAKE__
281
290
ecs_os_api .thread_new = bake_thread_new ;
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ ecs_entity_t new_row_system(
105
105
EcsRowSystem * system_data = ecs_get_ptr (world , result , EcsRowSystem );
106
106
memset (system_data , 0 , sizeof (EcsRowSystem ));
107
107
system_data -> base .action = action ;
108
- system_data -> base .signature = strdup (sig );
108
+ system_data -> base .signature = ecs_os_strdup (sig );
109
109
system_data -> base .enabled = true;
110
110
system_data -> base .invoke_count = 0 ;
111
111
system_data -> base .kind = kind ;
You can’t perform that action at this time.
0 commit comments