Skip to content

Commit 3ff8742

Browse files
committed
Adding webui_memcpy
* This can help wrappers like Bun
1 parent 27088bd commit 3ff8742

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/webui.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,17 @@ WEBUI_EXPORT void webui_free(void* ptr);
583583
*/
584584
WEBUI_EXPORT void* webui_malloc(size_t size);
585585

586+
/**
587+
* @brief Copy raw data.
588+
*
589+
* @param dest Destination memory pointer
590+
* @param src Source memory pointer
591+
* @param count Bytes to copy
592+
*
593+
* @example webui_memcpy(myBuffer, myData, 64);
594+
*/
595+
WEBUI_EXPORT void webui_memcpy(void* dest, void* src, size_t count);
596+
586597
/**
587598
* @brief Safely send raw data to the UI. All clients.
588599
*

src/webui.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,6 +3083,18 @@ void webui_free(void * ptr) {
30833083
_webui_free_mem(ptr);
30843084
}
30853085

3086+
void webui_memcpy(void* dest, void* src, size_t count) {
3087+
3088+
#ifdef WEBUI_LOG
3089+
printf("[User] webui_memcpy()\n");
3090+
printf("[User] webui_memcpy() -> Copying %zu bytes from [%p] to [%p]\n", count, src, dest);
3091+
#endif
3092+
3093+
if ((dest != NULL) && (src != NULL) && (count > 0)) {
3094+
memcpy(dest, src, count);
3095+
}
3096+
}
3097+
30863098
void * webui_malloc(size_t size) {
30873099

30883100
#ifdef WEBUI_LOG

0 commit comments

Comments
 (0)