Commit: 028f01ac3e015de8bf5aa1a97cda3a6b67bbe562
Parent: f11ad1c1b018ab2d164c47b7564d38db61dc049b
Author: Randy Palamar
Date: Fri, 21 Mar 2025 21:58:56 -0600
util: swap the argument order on mem_copy/mem_move
going against convention here was a bad idea
Diffstat:
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/beamformer.c b/beamformer.c
@@ -704,7 +704,7 @@ DEBUG_EXPORT BEAMFORMER_COMPLETE_COMPUTE_FN(beamformer_complete_compute)
if (did_sum_shader) {
ctx->averaged_frame.ready_to_present = 1;
/* TODO(rnp): not really sure what to do here */
- mem_copy(frame->stats->times, ctx->averaged_frame_compute_stats.times,
+ mem_copy(ctx->averaged_frame_compute_stats.times, frame->stats->times,
sizeof(frame->stats->times));
}
frame->store->ready_to_present = 1;
diff --git a/ui.c b/ui.c
@@ -1367,8 +1367,8 @@ update_text_input(InputState *is, Variable *var)
b32 allow_key = ((key >= '0' && key <= '9') || (key == '.') ||
(key == '-' && is->cursor == 0));
if (allow_key) {
- mem_move(is->buf + is->cursor,
- is->buf + is->cursor + 1,
+ mem_move(is->buf + is->cursor + 1,
+ is->buf + is->cursor,
is->buf_len - is->cursor + 1);
is->buf[is->cursor++] = key;
@@ -1386,16 +1386,16 @@ update_text_input(InputState *is, Variable *var)
if ((IsKeyPressed(KEY_BACKSPACE) || IsKeyPressedRepeat(KEY_BACKSPACE)) && is->cursor > 0) {
is->cursor--;
if (is->cursor < ARRAY_COUNT(is->buf) - 1) {
- mem_move(is->buf + is->cursor + 1,
- is->buf + is->cursor,
+ mem_move(is->buf + is->cursor,
+ is->buf + is->cursor + 1,
is->buf_len - is->cursor);
}
is->buf_len--;
}
if ((IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) && is->cursor < is->buf_len) {
- mem_move(is->buf + is->cursor + 1,
- is->buf + is->cursor,
+ mem_move(is->buf + is->cursor,
+ is->buf + is->cursor + 1,
is->buf_len - is->cursor);
is->buf_len--;
}
@@ -1727,7 +1727,7 @@ draw_ui(BeamformerCtx *ctx, BeamformerInput *input, BeamformFrame *frame_to_draw
/* TODO(rnp): there should be a better way of detecting this */
if (ctx->ui_read_params) {
- mem_copy(&ctx->params->raw.output_min_coordinate, &ui->params, sizeof(ui->params));
+ mem_copy(&ui->params, &ctx->params->raw.output_min_coordinate, sizeof(ui->params));
ui->flush_params = 0;
ctx->ui_read_params = 0;
}
@@ -1739,7 +1739,7 @@ draw_ui(BeamformerCtx *ctx, BeamformerInput *input, BeamformFrame *frame_to_draw
if (ui->flush_params) {
validate_ui_parameters(&ui->params);
if (!ctx->csctx.processing_compute) {
- mem_copy(&ui->params, &ctx->params->raw.output_min_coordinate, sizeof(ui->params));
+ mem_copy(&ctx->params->raw.output_min_coordinate, &ui->params, sizeof(ui->params));
ui->flush_params = 0;
ctx->params->upload = 1;
ctx->start_compute = 1;
diff --git a/util.c b/util.c
@@ -24,7 +24,7 @@ mem_clear(void *p_, u8 c, iz size)
}
static void
-mem_copy(void *restrict src, void *restrict dest, uz n)
+mem_copy(void *restrict dest, void *restrict src, uz n)
{
ASSERT(n >= 0);
u8 *s = src, *d = dest;
@@ -32,9 +32,9 @@ mem_copy(void *restrict src, void *restrict dest, uz n)
}
static void
-mem_move(u8 *src, u8 *dest, iz n)
+mem_move(u8 *dest, u8 *src, iz n)
{
- if (dest < src) mem_copy(src, dest, n);
+ if (dest < src) mem_copy(dest, src, n);
else while (n) { n--; dest[n] = src[n]; }
}
@@ -210,7 +210,7 @@ stream_append(Stream *s, void *data, iz count)
{
s->errors |= (s->cap - s->widx) < count;
if (!s->errors) {
- mem_copy(data, s->data + s->widx, count);
+ mem_copy(s->data + s->widx, data, count);
s->widx += count;
}
}
@@ -418,7 +418,7 @@ static s8
push_s8(Arena *a, s8 str)
{
s8 result = s8_alloc(a, str.len);
- mem_copy(str.data, result.data, result.len);
+ mem_copy(result.data, str.data, result.len);
return result;
}
@@ -427,7 +427,7 @@ push_s8_zero(Arena *a, s8 str)
{
s8 result = s8_alloc(a, str.len + 1);
result.len -= 1;
- mem_copy(str.data, result.data, result.len);
+ mem_copy(result.data, str.data, result.len);
return result;
}