Skip to main content

addwrapper

Function addwrapper 

Source
pub fn addwrapper(m: &str, w: funcwrap) -> i32
Expand description

Port of addwrapper() from Src/module.c:577. — C decl addwrapper(Module m, FuncWrap w). Tail-appends a module’s function wrapper onto the global WRAPPERS list. Returns 1 on error, 0 on success.

C body (c:578-600):

FuncWrap p, q;
if (m->node.flags & MOD_ALIAS)
    return 1;
if (w->flags & WRAPF_ADDED)
    return 1;
for (p = wrappers, q = NULL; p; q = p, p = p->next);
if (q)
    q->next = w;
else
    wrappers = w;
w->next = NULL;
w->flags |= WRAPF_ADDED;
w->module = m;
return 0;

WARNING: param types don’t match C — Rust=(m: &str, w) vs C=(Module m, FuncWrap w). Every zshrs module entry point is reached by NAME through the module.rs dispatcher (setup_module / boot_module / cleanup_module all take name: &str and hand the per-module *_ fn a null *const module), so a Module pointer is not available at the call site. The name is looked up in MODULESTAB for the c:586 MOD_ALIAS test and stored back into w.module — C keeps the pointer, this port keeps a name-carrying module node, which is what deletewrapper matches on.