about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedlibxtst.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-05-09 18:06:52 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-05-09 18:06:52 +0200
commit6ef734960abfb83501cf2236ae41624c0375f570 (patch)
treec4870f8113a7dd23fdd4c1fbd26d7796fb6b6317 /src/wrapped/wrappedlibxtst.c
parent244e3eafdf05ddef3b75c88c362ffc62ffbf2584 (diff)
downloadbox64-6ef734960abfb83501cf2236ae41624c0375f570.tar.gz
box64-6ef734960abfb83501cf2236ae41624c0375f570.zip
Some refactor on wrapped lib handling, to limit calloc/free used and get more straight forward usage of native wrapped functions (ported from box86)
Diffstat (limited to 'src/wrapped/wrappedlibxtst.c')
-rwxr-xr-xsrc/wrapped/wrappedlibxtst.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/src/wrapped/wrappedlibxtst.c b/src/wrapped/wrappedlibxtst.c
index df7b14c4..a99be56f 100755
--- a/src/wrapped/wrappedlibxtst.c
+++ b/src/wrapped/wrappedlibxtst.c
@@ -22,28 +22,7 @@ const char* libxtstName = "libXtst.so.6";
 
 #include "generated/wrappedlibxtsttypes.h"
 
-typedef struct libxtst_my_s {
-    #define GO(A, B)    B   A;
-    SUPER()
-    #undef GO
-    // functions
-} libxtst_my_t;
-
-void* getXtstMy(library_t* lib)
-{
-    libxtst_my_t* my = (libxtst_my_t*)calloc(1, sizeof(libxtst_my_t));
-    #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
-    SUPER()
-    #undef GO
-    return my;
-}
-#undef SUPER
-
-void freeXtstMy(void* lib)
-{
-    (void)lib;
-    //libxtst_my_t *my = (libxtst_my_t *)lib;
-}
+#include "wrappercallback.h"
 
 #define SUPER() \
 GO(0)   \
@@ -78,28 +57,20 @@ static void* find_XRecordInterceptProc_Fct(void* fct)
 EXPORT int my_XRecordEnableContextAsync(x64emu_t* emu, void* display, void* context, void* cb, void* closure)
 {
     (void)emu;
-    library_t* lib = GetLibInternal(libxtstName);
-    libxtst_my_t* my = (libxtst_my_t*)lib->priv.w.p2;
     return my->XRecordEnableContextAsync(display, context, find_XRecordInterceptProc_Fct(cb), closure);
 }
 
 EXPORT int my_XRecordEnableContext(x64emu_t* emu, void* display, void* context, void* cb, void* closure)
 {
     (void)emu;
-    library_t* lib = GetLibInternal(libxtstName);
-    libxtst_my_t* my = (libxtst_my_t*)lib->priv.w.p2;
     return my->XRecordEnableContext(display, context, find_XRecordInterceptProc_Fct(cb), closure);
 }
 
 #define CUSTOM_INIT \
-    lib->priv.w.p2 = getXtstMy(lib);   \
-    lib->priv.w.needed = 2; \
-    lib->priv.w.neededlibs = (char**)calloc(lib->priv.w.needed, sizeof(char*)); \
-    lib->priv.w.neededlibs[0] = strdup("libX11.so.6"); \
-    lib->priv.w.neededlibs[1] = strdup("libXext.so.6");
+    getMy(lib);     \
+    setNeededLibs(&lib->priv.w, 2, "libX11.so.6", "libXext.so.6");
 
 #define CUSTOM_FINI \
-    freeXtstMy(lib->priv.w.p2); \
-    free(lib->priv.w.p2);
+    freeMy();
 
 #include "wrappedlib_init.h"