Skip to content

Commit

Permalink
tools: fix polyfill.h to be compilable from C++
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Jan 6, 2025
1 parent 9e8e53f commit 2787538
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/common/polyfill.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
}

if (*lineptr == NULL) {
*lineptr = malloc(128);
*lineptr = (char*)malloc(128);
if (*lineptr == NULL) {
return -1;
}
Expand All @@ -51,7 +51,7 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
if (new_size < 128) {
new_size = 128;
}
char *new_ptr = realloc(*lineptr, new_size);
char *new_ptr = (char*)realloc(*lineptr, new_size);
if (new_ptr == NULL) {
return -1;
}
Expand All @@ -74,7 +74,7 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
char *ret = malloc(len + 1);
char *ret = (char*)malloc(len + 1);
if (!ret) return NULL;
memcpy(ret, s, len);
ret[len] = '\0';
Expand Down Expand Up @@ -126,7 +126,7 @@ char* strcasestr(const char* haystack, const char* needle)
// Implementation from FreeBSD
void *memmem(const void *l, size_t l_len, const void *s, size_t s_len)
{
register char *cur, *last;
char *cur, *last;
const char *cl = (const char *)l;
const char *cs = (const char *)s;

Expand Down

0 comments on commit 2787538

Please sign in to comment.