Skip to content

Commit 0de49f0

Browse files
committed
fix(generator): simplify concatenated extension construction for EGL
We don't need strcat, we already have lengths calculated, we can just use memcpy. And this eliminates some 'strcat' usage warnings from MSVC as well. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
1 parent cf0a534 commit 0de49f0

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/generator/c/templates/source.c.j2

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,15 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
305305
/* Concatenate with a space separator. */
306306
concat = (char *)malloc(client_len + display_len + 2);
307307
if (!concat) return 0;
308-
concat[0] = '\0';
309-
strcat(concat, client_str);
308+
memcpy(concat, client_str, client_len);
309+
size_t pos = client_len;
310310
if (display_len) {
311-
if (client_len && concat[client_len - 1] != ' ')
312-
strcat(concat, " ");
313-
strcat(concat, display_str);
311+
if (client_len && client_str[client_len - 1] != ' ')
312+
concat[pos++] = ' ';
313+
memcpy(concat + pos, display_str, display_len);
314+
pos += display_len;
314315
}
316+
concat[pos] = '\0';
315317

316318
/* Two-pass: count then fill. */
317319
for (j = 0; j < 2; ++j) {

0 commit comments

Comments
 (0)