|
1 | 1 | #include "prism/util/pm_string.h" |
2 | 2 |
|
| 3 | +static const uint8_t empty_source[] = ""; |
| 4 | + |
3 | 5 | /** |
4 | 6 | * Returns the size of the pm_string_t struct. This is necessary to allocate the |
5 | 7 | * correct amount of memory in the FFI backend. |
@@ -133,8 +135,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) { |
133 | 135 | // the source to a constant empty string and return. |
134 | 136 | if (file_size == 0) { |
135 | 137 | pm_string_file_handle_close(&handle); |
136 | | - const uint8_t source[] = ""; |
137 | | - *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 }; |
| 138 | + *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 }; |
138 | 139 | return PM_STRING_INIT_SUCCESS; |
139 | 140 | } |
140 | 141 |
|
@@ -182,8 +183,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) { |
182 | 183 |
|
183 | 184 | if (size == 0) { |
184 | 185 | close(fd); |
185 | | - static const uint8_t source[] = ""; |
186 | | - *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 }; |
| 186 | + *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 }; |
187 | 187 | return PM_STRING_INIT_SUCCESS; |
188 | 188 | } |
189 | 189 |
|
@@ -225,8 +225,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) { |
225 | 225 | // the source to a constant empty string and return. |
226 | 226 | if (file_size == 0) { |
227 | 227 | pm_string_file_handle_close(&handle); |
228 | | - const uint8_t source[] = ""; |
229 | | - *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 }; |
| 228 | + *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 }; |
230 | 229 | return PM_STRING_INIT_SUCCESS; |
231 | 230 | } |
232 | 231 |
|
@@ -278,8 +277,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) { |
278 | 277 | size_t size = (size_t) sb.st_size; |
279 | 278 | if (size == 0) { |
280 | 279 | close(fd); |
281 | | - static const uint8_t source[] = ""; |
282 | | - *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 }; |
| 280 | + *string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 }; |
283 | 281 | return PM_STRING_INIT_SUCCESS; |
284 | 282 | } |
285 | 283 |
|
|
0 commit comments