Hot reloading + state saving

This commit is contained in:
2024-05-31 02:11:05 +03:00
parent 3b68f2dfda
commit a4e73470e2
11 changed files with 455 additions and 53 deletions

35
src/modules/example.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stdlib.h>
#include <assert.h>
typedef struct plug_t {
char* name; // Always keep these on top
char* version;
} plug_t;
static plug_t* p = {0};
void* plug_init(void) {
p = malloc(sizeof(plug_t));
assert(p);
p->name = "example";
p->version = "0.0.1";
return p;
}
void* plug_pre_reload(void) {
return p; // send state to dim
}
void plug_post_reload(void* pp) {
p = pp; // get back state
}
void plug_poll(char* buf, size_t len) {
// print text to `buf` with max len `len`
}
void plug_free(void) {
free(p); // free state
}