aboutsummaryrefslogtreecommitdiff
path: root/src/gb
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-05-20 17:31:46 +0100
committergingerBill <bill@gingerbill.org>2018-05-20 17:31:46 +0100
commit4d052d5119653c80f4c7b7c6695256e0540a55a5 (patch)
tree0093201366301e0178863a44e149f04bc673d22d /src/gb
parent7e4c6434012fbe4e8d76f9fb852a0f136c7bc795 (diff)
Remove code relating to default struct values
Diffstat (limited to 'src/gb')
-rw-r--r--src/gb/gb.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gb/gb.h b/src/gb/gb.h
index eb838702b..b2997eccd 100644
--- a/src/gb/gb.h
+++ b/src/gb/gb.h
@@ -3673,7 +3673,8 @@ gb_inline void *gb_memcopy(void *dest, void const *source, isize n) {
return NULL;
}
- __asm__ __volatile__("rep movsb" : "+D"(dest), "+S"(source), "+c"(n) : : "memory");
+ void *dest_copy = dest;
+ __asm__ __volatile__("rep movsb" : "+D"(dest_copy), "+S"(source), "+c"(n) : : "memory");
#else
u8 *d = cast(u8 *)dest;
u8 const *s = cast(u8 const *)source;
@@ -3798,12 +3799,15 @@ gb_inline void *gb_memcopy(void *dest, void const *source, isize n) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
}
- if (n & 4)
+ if (n & 4) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
- if (n & 2)
+ }
+ if (n & 2) {
*d++ = *s++; *d++ = *s++;
- if (n & 1)
+ }
+ if (n & 1) {
*d = *s;
+ }
}
#endif
@@ -4027,10 +4031,10 @@ gb_inline void *gb_resize (gbAllocator a, void *ptr, isize old_size, isize
gb_inline void *gb_resize_align(gbAllocator a, void *ptr, isize old_size, isize new_size, isize alignment) { return a.proc(a.data, gbAllocation_Resize, new_size, alignment, ptr, old_size, GB_DEFAULT_ALLOCATOR_FLAGS); }
gb_inline void *gb_alloc_copy (gbAllocator a, void const *src, isize size) {
- return gb_memmove(gb_alloc(a, size), src, size);
+ return gb_memcopy(gb_alloc(a, size), src, size);
}
gb_inline void *gb_alloc_copy_align(gbAllocator a, void const *src, isize size, isize alignment) {
- return gb_memmove(gb_alloc_align(a, size, alignment), src, size);
+ return gb_memcopy(gb_alloc_align(a, size, alignment), src, size);
}
gb_inline char *gb_alloc_str(gbAllocator a, char const *str) {
@@ -4039,8 +4043,7 @@ gb_inline char *gb_alloc_str(gbAllocator a, char const *str) {
gb_inline char *gb_alloc_str_len(gbAllocator a, char const *str, isize len) {
char *result;
- result = cast(char *)gb_alloc(a, len+1);
- gb_memmove(result, str, len);
+ result = cast(char *)gb_alloc_copy(a, str, len+1);
result[len] = '\0';
return result;
}
@@ -6548,7 +6551,7 @@ gbString gb_string_make_length(gbAllocator a, void const *init_str, isize num_by
header->allocator = a;
header->length = num_bytes;
header->capacity = num_bytes;
- if (num_bytes > 0 && init_str) {
+ if (num_bytes && init_str) {
gb_memcopy(str, init_str, num_bytes);
}
str[num_bytes] = '\0';
@@ -8480,9 +8483,9 @@ gb_no_inline isize gb_snprintf_va(char *text, isize max_len, char const *fmt, va
int width = va_arg(va, int);
if (width < 0) {
info.flags |= gbFmt_Minus;
- info.width = -info.width;
+ info.width = -width;
} else {
- info.width = -info.width;
+ info.width = width;
}
fmt++;
} else {
@@ -10813,4 +10816,3 @@ GB_COMPARE_PROC(gb_video_mode_dsc_cmp) {
#endif
#endif // GB_IMPLEMENTATION
-