Fixed bacnet_strdup() to compile with C89/C90 without warnings.

This commit is contained in:
Steve Karg
2026-03-07 11:55:31 -06:00
parent 926bc17801
commit bd29f1039d
+10 -7
View File
@@ -2196,13 +2196,16 @@ int bacnet_snprintf(
*/ */
char *bacnet_strdup(const char *s) char *bacnet_strdup(const char *s)
{ {
if (s == NULL) { size_t size;
return NULL; char *p = NULL;
}
size_t size = strlen(s) + 1; if (s) {
char *p = malloc(size); size = strlen(s) + 1;
if (p != NULL) { p = malloc(size);
memcpy(p, s, size); if (p != NULL) {
memcpy(p, s, size);
}
} }
return p; return p;
} }