summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/al/str.h34
-rw-r--r--include/al/wstr.h24
2 files changed, 29 insertions, 29 deletions
diff --git a/include/al/str.h b/include/al/str.h
index e9ac8f2..a3ddd8e 100644
--- a/include/al/str.h
+++ b/include/al/str.h
@@ -14,19 +14,19 @@ typedef struct {
#define al_str_null() ((str){ 0, 0, NULL })
-#define al_str_at(s, i) (s)->data[i]
-#define al_str_atr(s, i) (s)->data[(s)->length - (i)]
+#define al_str_at(s, index) (s)->data[index]
+#define al_str_atr(s, index) (s)->data[(s)->length - (index)]
#define al_chars_if_literal(s) ((char *)(s "")) // use al_str_cs/cr for non-static arrays.
#define al_str_c(c) ((str){ (u32)(sizeof(c) - 1), 0, al_chars_if_literal(c) })
#define al_str_cs(c) ((str){ (u32)al_strnlen(c, sizeof(c)), 0, ((char *)(c)) }) // (s)ized
#define al_str_cr(c) ((str){ (u32)al_strnlen(c, MAX_ALLOC_32), 0, ((char *)(c)) }) // (r)untime
-#define al_str_w(c, i, n) ((str){ ((u32)(n)), 0, (c) + (i) })
+#define al_str_w(c, index, n) ((str){ ((u32)(n)), 0, (c) + (index) })
#define al_str_substr(s, start, end) al_str_w((s)->data, start, ((end) - (start)))
#define al_str_x(s) (s)->length, (s)->data // e(x)pand
-#define al_str_x_maxlen(s, l) MIN((s)->length, (l)), (s)->data
+#define al_str_x_maxlen(s, len) MIN((s)->length, (len)), (s)->data
static inline bool al_str_is_empty(str *s)
{
@@ -74,10 +74,10 @@ static inline void al_str_to_lower(str *s)
// Returned c_str must be free'd by the user.
static inline char *al_str_to_c_str(str *s)
{
- char *c = (char *)al_malloc(s->length + 1);
- al_memcpy(c, s->data, s->length);
- c[s->length] = '\0';
- return c;
+ char *c_str = (char *)al_malloc(s->length + 1);
+ al_memcpy(c_str, s->data, s->length);
+ c_str[s->length] = '\0';
+ return c_str;
}
static inline void al_str_cat(str *s, str *c)
@@ -87,14 +87,14 @@ static inline void al_str_cat(str *s, str *c)
s->length += c->length;
}
-static inline void al_str_insert(str *s, u32 i, str *c)
+static inline void al_str_insert(str *s, u32 index, str *c)
{
s->alloc = al_str_reserve(s, s->length + c->length);
- char *data = s->data + i;
- if (i < s->length) {
- al_memmove(data + c->length, data, s->length - i);
+ char *pos = s->data + index;
+ if (index < s->length) {
+ al_memmove(pos + c->length, pos, s->length - index);
}
- al_memcpy(data, c->data, c->length);
+ al_memcpy(pos, c->data, c->length);
s->length += c->length;
}
@@ -103,11 +103,11 @@ static inline void al_str_prepend(str *s, str *c)
al_str_insert(s, 0, c);
}
-static inline void al_str_remove_at(str *s, u32 i)
+static inline void al_str_remove_at(str *s, u32 index)
{
- al_assert(i < s->length);
- if (i != --s->length) {
- al_memmove(s->data + i, s->data + i + 1, s->length - i);
+ al_assert(index < s->length);
+ if (index != --s->length) {
+ al_memmove(s->data + index, s->data + index + 1, s->length - index);
}
}
diff --git a/include/al/wstr.h b/include/al/wstr.h
index f700037..27239d9 100644
--- a/include/al/wstr.h
+++ b/include/al/wstr.h
@@ -16,15 +16,15 @@ typedef struct {
#define al_wstr_null() ((wstr){ 0, 0, NULL })
-#define al_wstr_at(w, i) (w)->data[i]
-#define al_wstr_atr(w, i) (w)->data[(w)->length - (i)]
+#define al_wstr_at(w, index) (w)->data[index]
+#define al_wstr_atr(w, index) (w)->data[(w)->length - (index)]
#define al_wide_chars_if_literal(wc) ((wchar_t *)(L"" wc)) // use al_wstr_cs/r for non-static arrays.
#define al_wstr_c(wc) ((wstr){ (u32)((sizeof(wc) / sizeof(wchar_t)) - 1), 0, al_wide_chars_if_literal(wc) })
#define al_wstr_cs(wc) ((wstr){ (u32)wcsnlen(wc, sizeof(wc)), 0, ((wchar_t *)(wc)) }) // (s)ized
#define al_wstr_cr(wc) ((wstr){ (u32)wcsnlen(wc, MAX_ALLOC_32), 0, ((wchar_t *)(wc)) }) // (r)untime
-#define al_wstr_w(wc, i, n) ((wstr){ ((u32)(n)), 0, (wc) + (i) })
+#define al_wstr_w(wc, index, n) ((wstr){ ((u32)(n)), 0, (wc) + (index) })
#define al_wstr_substr(w, start, end) al_wstr_w((w)->data, start, ((end) - (start)))
#define al_wstr_x(w) (w)->data // e(x)pand
@@ -133,23 +133,23 @@ static inline void al_wstr_cat(wstr *w, wstr *c)
w->data[w->length] = L'\0';
}
-static inline void al_wstr_insert(wstr *w, u32 i, wstr *c)
+static inline void al_wstr_insert(wstr *w, u32 index, wstr *c)
{
w->alloc = al_wstr_reserve(w, ((w->length + c->length) + 1) * sizeof(wchar_t));
- wchar_t *data = w->data + i;
- if (i < w->length) {
- al_memmove(data + c->length, data, (w->length - i) * sizeof(wchar_t));
+ wchar_t *pos = w->data + index;
+ if (index < w->length) {
+ al_memmove(pos + c->length, pos, (w->length - index) * sizeof(wchar_t));
}
- al_memcpy(data, c->data, c->length * sizeof(wchar_t));
+ al_memcpy(pos, c->data, c->length * sizeof(wchar_t));
w->length += c->length;
w->data[w->length] = L'\0';
}
-static inline void al_wstr_remove_at(wstr *w, u32 i)
+static inline void al_wstr_remove_at(wstr *w, u32 index)
{
- al_assert(i < w->length);
- if (i != --w->length) {
- al_memmove(w->data + i, w->data + i + 1, (w->length - i) * sizeof(wchar_t));
+ al_assert(index < w->length);
+ if (index != --w->length) {
+ al_memmove(w->data + index, w->data + index + 1, (w->length - index) * sizeof(wchar_t));
}
w->data[w->length] = L'\0';
}