Skip to content

Commit f049f6d

Browse files
Use ruby_strdup built into ruby.
1 parent aebbf2f commit f049f6d

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

ext/rugged/rugged.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <ruby/encoding.h>
2121
#endif
2222

23+
#include <ruby/util.h>
24+
2325
#include <assert.h>
2426
#include <git2.h>
2527
#include <git2/odb_backend.h>

ext/rugged/rugged_allocator.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ static void *rugged_gcalloc(size_t nelem, size_t elsize, const char *file, int l
2020

2121
static char *rugged_gstrdup(const char *str, const char *file, int line)
2222
{
23-
char *newstr;
24-
size_t n;
25-
26-
n = strlen(str);
27-
newstr = xmalloc(n+1);
28-
memcpy(newstr, str, n);
29-
newstr[n] = '\0';
30-
31-
return newstr;
23+
return ruby_strdup(str);
3224
}
3325

3426
static char *rugged_gstrndup(const char *str, size_t n, const char *file, int line)

0 commit comments

Comments
 (0)