12 *out = strcmp(lhs, rhs) == 0 ? 1 : 0;
19 *out = lmmc_std_text_hash_bytes(value);
23static char* lmmc_std_text_copy(
const char* value)
25 size_t length = strlen(value);
27 if (length == (
size_t)-1) {
return NULL; }
29 if (!copy) {
return NULL; }
30 memcpy(copy, value, length + 1);
36 if (!set) {
return 0; }
37 if (set->
size == 0) {
return 1; }
38 if (!set->
data) {
return 0; }
39 for (
size_t i = 0; i < set->
size; ++i) {
40 if (!set->
data[i]) {
return 0; }
48 for (
size_t i = 0; i < set->
size; ++i) {
49 if (strcmp(set->
data[i], value) == 0) {
return 1; }
63 if (!lmmc_safe_mul_size(capacity,
sizeof(
char*), &bytes)) {
68 memset(out->
data, 0, bytes);
79 if (lmmc_std_text_set_contains_value(set, value)) {
return LMMC_STATUS_OK; }
81 copy = lmmc_std_text_copy(value);
93 status = lmmc_std_text_set_alloc(count, out);
95 for (
size_t i = 0; i < count; ++i) {
96 status = lmmc_std_text_set_append_unique(out, values[i]);
109 for (
size_t i = 0; i < set->
size; ++i) {
127 *out = lmmc_std_text_set_contains_value(set, value);
135 if (!out || !lmmc_std_text_set_valid(lhs) ||
136 !lmmc_std_text_set_valid(rhs)) {
139 for (
size_t i = 0; i < lhs->
size; ++i) {
140 if (!lmmc_std_text_set_contains_value(rhs, lhs->
data[i])) {
154 if (!out || (
const void*)out == (
const void*)lhs ||
155 (
const void*)out == (
const void*)rhs ||
156 !lmmc_std_text_set_valid(lhs) || !lmmc_std_text_set_valid(rhs)) {
159 if (lhs->
size > ((
size_t)-1) - rhs->
size) {
162 return lmmc_std_text_set_alloc(lhs->
size + rhs->
size, out);
169 lmmc_status_t status = lmmc_std_text_set_binary_alloc(lhs, rhs, out);
171 for (
size_t i = 0; i < lhs->
size; ++i) {
172 status = lmmc_std_text_set_append_unique(out, lhs->
data[i]);
177 for (
size_t i = 0; i < rhs->
size; ++i) {
178 status = lmmc_std_text_set_append_unique(out, rhs->
data[i]);
193 lmmc_status_t status = lmmc_std_text_set_binary_alloc(lhs, rhs, out);
195 for (
size_t i = 0; i < lhs->
size; ++i) {
196 if (lmmc_std_text_set_contains_value(rhs, lhs->
data[i])) {
197 status = lmmc_std_text_set_append_unique(out, lhs->
data[i]);
213 lmmc_status_t status = lmmc_std_text_set_binary_alloc(lhs, rhs, out);
215 for (
size_t i = 0; i < lhs->
size; ++i) {
216 if (!lmmc_std_text_set_contains_value(rhs, lhs->
data[i])) {
217 status = lmmc_std_text_set_append_unique(out, lhs->
data[i]);
234 lmmc_status_t status = lmmc_std_text_set_binary_alloc(lhs, rhs, out);
236 for (
size_t i = 0; i < lhs->
size; ++i) {
237 if (!lmmc_std_text_set_contains_value(rhs, lhs->
data[i])) {
238 status = lmmc_std_text_set_append_unique(out, lhs->
data[i]);
244 for (
size_t i = 0; i < rhs->
size; ++i) {
245 if (!lmmc_std_text_set_contains_value(lhs, rhs->
data[i])) {
246 status = lmmc_std_text_set_append_unique(out, rhs->
data[i]);
void * lmmc_memory_alloc(size_t size)
void * lmmc_memory_alloc_array_plus(size_t count, size_t extra, size_t element_size)
void lmmc_memory_free(void *pointer)
Private recoverable allocator for persistent LMMC ownership.
lmmc_status_t
LMMC 库统一返回的状态码.
@ LMMC_STATUS_ALLOCATION_FAILED
@ LMMC_STATUS_INVALID_ARGUMENT
lmmc_status_t lmmc_std_text_hash(const char *value, uint64_t *out)
为 LSR 规范的表键计算 UTF-8 文本哈希。
lmmc_status_t lmmc_std_text_set_symmetric_difference(const lmmc_std_text_set_t *lhs, const lmmc_std_text_set_t *rhs, lmmc_std_text_set_t *out)
lmmc_status_t lmmc_std_text_equal(const char *lhs, const char *rhs, int *out)
按 LSR 规范的表键语义比较 UTF-8 文本值。
lmmc_status_t lmmc_std_text_set_union(const lmmc_std_text_set_t *lhs, const lmmc_std_text_set_t *rhs, lmmc_std_text_set_t *out)
lmmc_status_t lmmc_std_text_set_difference(const lmmc_std_text_set_t *lhs, const lmmc_std_text_set_t *rhs, lmmc_std_text_set_t *out)
lmmc_status_t lmmc_std_text_set_make(const char *const *values, size_t count, lmmc_std_text_set_t *out)
构造去重的文本集合。
void lmmc_std_text_set_destroy(lmmc_std_text_set_t *set)
lmmc_status_t lmmc_std_text_set_intersection(const lmmc_std_text_set_t *lhs, const lmmc_std_text_set_t *rhs, lmmc_std_text_set_t *out)
lmmc_status_t lmmc_std_text_set_contains(const lmmc_std_text_set_t *set, const char *value, int *out)
lmmc_status_t lmmc_std_text_set_subset(const lmmc_std_text_set_t *lhs, const lmmc_std_text_set_t *rhs, int *out)