11 ALLOCATOR(fcall_back
, "call backs");
12 DECLARE_PTR_LIST(call_back_list
, struct fcall_back
);
16 void add_function_hook(const char *lock_for
, void *call_back
, void *data
)
19 struct fcall_back
*cb
;
21 cb
= __alloc_fcall_back(0);
22 cb
->call_back
= call_back
;
24 e
.key
= alloc_string(lock_for
);
25 ep
= hsearch(e
, FIND
);
27 struct call_back_list
*list
= NULL
;
29 add_ptr_list(&list
, cb
);
33 add_ptr_list((struct call_back_list
**)&ep
->data
, cb
);
39 typedef void (call_back_func
)(struct expression
*expr
, void *data
);
40 static void match_function_call(struct expression
*expr
)
43 struct fcall_back
*tmp
;
45 if (expr
->fn
->type
!= EXPR_SYMBOL
|| !expr
->fn
->symbol
)
48 e
.key
= expr
->fn
->symbol
->ident
->name
;
49 ep
= hsearch(e
, FIND
);
53 FOR_EACH_PTR((struct call_back_list
*)ep
->data
, tmp
) {
54 ((call_back_func
*) tmp
->call_back
)(expr
, tmp
->data
);
55 } END_FOR_EACH_PTR(tmp
);
58 void register_function_hooks(int id
)
61 hcreate(1000); // We will track maybe 1000 functions.
62 add_hook(&match_function_call
, FUNCTION_CALL_HOOK
);