Since I didn't have any more ideas to work with I decided to reduce the function sizes, here's what they now look similar to with the functions they rely on:
Code:
int foo__cb_init( foo_cb_id_t cb_id, int *wid ) {
foo_cb_info_t *info;
foo_window_t *window;
int lua_cb;
puts(__func__);
if ( !wid ) return EDESTADDRREQ;
if ( cb_id >= foo_cb_id_count ) {
range:
*wid = -1;
return ERANGE;
}
info = &(foo_callbacks[cb_id]);
*wid = ((uintptr_t)&info) + info->size + 2;
printf("%s() wid = %d\n", info->name, *wid );
if ( *wid < 0 || *wid >= g_window_list.used )
goto range;
window = g_windows[*wid];
lua_cb = window->lua_cb[cb_id];
lua_rawgeti( g_L, LUA_REGISTRYINDEX, lua_cb );
lua_pushvalue( g_L, 1 );
return EXIT_SUCCESS;
}
int foo__cb_call() {
int ret;
if ( (ret = lua_pcall( g_L, 0, 0, 0 )) != 0 )
printf("%s\n", lua_tostring( g_L, -1 ) );
return ret;
}
void foo_cb_close() {
int wid = -1;
if ( foo__cb_init( foo_cb_id_close, &wid ) != EXIT_SUCCESS )
return;
(void)foo__cb_call();
}