19.0.0 released Nov 08, 2023 |
set-app process-data <data>
get-app process-data to <data>
#ifndef _MY #define _MY typedef struct s_procdata { bool some_flag; bool another_flag; char *ptr; } procdata; #endif
#include "vely.h" #include "my.h" void _startup () { procdata *rd; // A pointer to global request data // Use unmanaged memory for process-wide data manage-memory off // Allocate global request data new-mem rd size sizeof(procdata) // Turn back on managed memory manage-memory on // Initialize values in it rd->some_flag = false; rd->another_flag = false; // Save the pointer so you can use it anywhere with get-req set-app process-data rd }
#include "vely.h" #include "my.h" request-handler /mycode ... procdata *mydata; // declare local pointer // get the actual value of a pointer, so now it points to global request data get-app process-data to mydata // do whatever you want with the data: examine, set etc. if (mydata->another_flag) { mydata->some_flag = true; // If you free, allocate or reallocate global-process data, use unmanaged memory manage-memory off resize-mem my_data->ptr size 1024 manage-memory on } end-request-handler