ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | LICENSE

Commit: 933c75ad2e71058d22204a97ef57cf1536acb3b6
Parent: 424ac3effa64f7cb5120ffaa594120621920578f
Author: Randy Palamar
Date:   Wed, 14 Aug 2024 16:15:24 -0600

replace memmove

Diffstat:
Mbeamformer.c | 17++++++-----------
Mutil.c | 7+++++++
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/beamformer.c b/beamformer.c @@ -1,9 +1,6 @@ /* See LICENSE for license details. */ #include "beamformer.h" -/* TODO: remove this */ -#include <string.h> /* memmove */ - static void alloc_output_image(BeamformerCtx *ctx) { @@ -273,10 +270,9 @@ do_text_input(BeamformerCtx *ctx, i32 max_chars, Rect r, Color colour) b32 allow_key = ((key >= '0' && key <= '9') || (key == '.') || (key == '-' && ctx->is.cursor == 0)); if (allow_key) { - /* TODO: remove memmove */ - memmove(ctx->is.buf + ctx->is.cursor + 1, - ctx->is.buf + ctx->is.cursor, - ctx->is.buf_len - ctx->is.cursor + 1); + mem_move(ctx->is.buf + ctx->is.cursor, + ctx->is.buf + ctx->is.cursor + 1, + ctx->is.buf_len - ctx->is.cursor + 1); ctx->is.buf[ctx->is.cursor++] = key; ctx->is.buf_len++; @@ -293,11 +289,10 @@ do_text_input(BeamformerCtx *ctx, i32 max_chars, Rect r, Color colour) if ((IsKeyPressed(KEY_BACKSPACE) || IsKeyPressedRepeat(KEY_BACKSPACE)) && ctx->is.cursor > 0) { - /* TODO: remove memmove */ ctx->is.cursor--; - memmove(ctx->is.buf + ctx->is.cursor, - ctx->is.buf + ctx->is.cursor + 1, - ctx->is.buf_len - ctx->is.cursor - 1); + mem_move(ctx->is.buf + ctx->is.cursor + 1, + ctx->is.buf + ctx->is.cursor, + ctx->is.buf_len - ctx->is.cursor); ctx->is.buf[--ctx->is.buf_len] = 0; } } diff --git a/util.c b/util.c @@ -22,6 +22,13 @@ mem_clear(u8 *p, u8 c, size len) return p; } +static void +mem_move(char *src, char *dest, size n) +{ + if (dest < src) while (n) { *dest++ = *src++; n--; } + else while (n) { n--; dest[n] = src[n]; } +} + #define alloc(a, t, n) (t *)alloc_(a, sizeof(t), _Alignof(t), n) __attribute((malloc, alloc_size(4, 2), alloc_align(3))) static void *