core: 补全 layout 注册表与结果集接口
- 新增 src/core/layout.c,实现 layout result 和 registry 的基础操作 - 精简 wm_layout_ctx_t,改为按顺序传递参与布局的窗口 id 列表 - 为 layout API 补充中文前置条件说明 - 在 utils 中补充 p_strdup 和容量扩展辅助函数
This commit is contained in:
12
src/utils.h
12
src/utils.h
@@ -28,6 +28,12 @@
|
||||
#define unlikely(expr) expr
|
||||
#endif
|
||||
|
||||
static inline char *p_strdup(const char *text) {
|
||||
char *r = strdup(text);
|
||||
if (!r) abort();
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void *__attribute__((malloc)) xmalloc(ssize_t size) {
|
||||
void *ptr;
|
||||
|
||||
@@ -101,3 +107,9 @@ static inline void logger(const char *format, ...) {
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static constexpr size_t INIT_CAPACITY = 4;
|
||||
static inline size_t next_capacity(size_t capacity) {
|
||||
if (capacity) return capacity * 2;
|
||||
return INIT_CAPACITY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user