From 1d8b2adc084d684b90ec525e342b7a3a159a0474 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 16 Jul 2020 16:53:00 +0200 Subject: Renamed cstring_release to cstring_move, and removed old cstring_move func. --- stc/chash.h | 2 +- stc/cstring.h | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/stc/chash.h b/stc/chash.h index 8cc6fbb4..aa6ceadc 100644 --- a/stc/chash.h +++ b/stc/chash.h @@ -237,7 +237,7 @@ chash_##tag##_bucket(const CHash_##tag* self, const CHashRawKey_##tag* rawKeyPtr \ STC_API CHashEntry_##tag* \ chash_##tag##_get(const CHash_##tag* self, CHashRawKey_##tag rawKey) { \ - if (chash_bucketCount(*self) == 0) return NULL; \ + if (chash_size(*self) == 0) return NULL; \ uint32_t hx; \ size_t idx = chash_##tag##_bucket(self, &rawKey, &hx); \ return self->_hashx[idx] ? &self->table[idx] : NULL; \ diff --git a/stc/cstring.h b/stc/cstring.h index ca22c4d5..5ce9b868 100644 --- a/stc/cstring.h +++ b/stc/cstring.h @@ -162,19 +162,11 @@ cstring_take(CString* self, CString s) { } static inline CString -cstring_release(CString* self) { +cstring_move(CString* self) { CString tmp = *self; *self = cstring_init; return tmp; } -/* cstring_move(&s1, &s2) short for: cstring_take(&s1, cstring_release(&s2)) */ -static inline CString* -cstring_move(CString* self, CString* s) { - cstring_take(self, *s); - *s = cstring_init; - return self; -} - static inline CString* cstring_appendN(CString* self, const char* str, size_t len) { @@ -187,12 +179,15 @@ cstring_appendN(CString* self, const char* str, size_t len) { } return self; } - static inline CString* cstring_append(CString* self, const char* str) { return cstring_appendN(self, str, strlen(str)); } static inline CString* +cstring_appendC(CString* self, char ch) { + return cstring_appendN(self, &ch, 1); +} +static inline CString* cstring_appendS(CString* self, CString s) { return cstring_appendN(self, s.str, cstring_size(s)); } -- cgit v1.2.3