diff --git a/math.c b/math.c index efe46b3..ea2c63f 100644 --- a/math.c +++ b/math.c @@ -149,6 +149,13 @@ fn u64 u64SafeMul(u64 x, u64 y) { fn f32 f32FromString(String s) { f32 result = 0.0f; if (s.length == 0) { return result; } + // TODO handle +/- for sign + /* + * while (*s == ' ') s++; + float sign = 1.0f; + if (*s == '-') { sign = -1.0f; s++; } + else if (*s == '+') s++; + * */ ptr c = s.bytes; while (*c >= '0' && *c <= '9') { result = result * 10.0f + (*c++ - '0'); diff --git a/string.c b/string.c index dc5cf78..dba0eae 100644 --- a/string.c +++ b/string.c @@ -494,7 +494,11 @@ fn bool stringInsertBytesAtMaybeAlloc(Arena* a, String* s, str bytes, u32 at) { bool is_already_enough_space = stringInsertBytesAt(s, bytes, at); if (!is_already_enough_space) { ptr old_bytes = s->bytes; - s->bytes = arenaAllocZero(a, s->capacity + 64); + u32 len = strlen(bytes); + u32 available_cap = s->capacity - s->length; + assert(len > available_cap); + s->capacity += (len - available_cap); + s->bytes = arenaAllocZero(a, s->capacity); MemoryCopy(s->bytes, old_bytes, s->length); return stringInsertBytesAt(s, bytes, at); }