HAL_ChibiOS: fixed strdup() on ChibiOS

This commit is contained in:
Andrew Tridgell 2020-03-12 14:24:42 +11:00
parent 1b5e5de0d1
commit 822460ce7d

View File

@ -287,3 +287,18 @@ void memory_flush_all(void)
stm32_cacheBufferFlush(memory_regions[i].address, memory_regions[i].size);
}
}
/*
replacement for strdup
*/
char *strdup(const char *str)
{
const size_t len = strlen(str);
char *ret = malloc(len+1);
if (!ret) {
return NULL;
}
memcpy(ret, str, len);
ret[len] = 0;
return ret;
}