Skip to content

Commit

Permalink
use nng_alloc() for strcat()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 27, 2023
1 parent 7b95101 commit 0b590a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,12 +1383,13 @@ SEXP rnng_strcat(SEXP a, SEXP b) {
const size_t alen = strlen(ap);
const size_t blen = strlen(bp);

char *buf = R_alloc(sizeof(char), alen + blen + 1);
char *buf = nng_alloc(alen + blen + 1);
memcpy(buf, ap, alen);
memcpy(buf + alen, bp, blen + 1);

PROTECT(out = Rf_allocVector(STRSXP, 1));
SET_STRING_ELT(out, 0, Rf_mkCharLenCE(buf, alen + blen, CE_NATIVE));
nng_free(buf, alen + blen + 1);

UNPROTECT(1);
return out;
Expand Down

0 comments on commit 0b590a2

Please sign in to comment.