utils: 添加 p_strdup_nullable 辅助函数

This commit is contained in:
2026-03-23 09:55:47 +08:00
parent 577c5bc3b2
commit 38572bd5f7
3 changed files with 11 additions and 6 deletions

View File

@@ -36,6 +36,11 @@ static inline char *p_strdup(const char *text) {
return r;
}
static inline char *p_strdup_nullable(const char *text) {
if (!text) return nullptr;
return p_strdup(text);
}
static inline void *__attribute__((malloc)) xmalloc(ssize_t size) {
void *ptr;