@@ -957,7 +957,7 @@ hjs_hookcmd (JSContext *context, unsigned argc, jsval *vp)
957957 char * ccmdstr;
958958 int pri = HEXCHAT_PRI_NORM;
959959 hexchat_hook* hexhook;
960- script_hook* hook = new script_hook ;
960+ script_hook* hook;
961961 js_script* script = hjs_script_find (context);
962962
963963 // these are slightly out of normal order, does jsapi have kwargs?
@@ -972,6 +972,7 @@ hjs_hookcmd (JSContext *context, unsigned argc, jsval *vp)
972972 if (helpstr)
973973 chelpstr = JSSTRING_TO_CHAR (helpstr);
974974
975+ hook = new script_hook;
975976 hexhook = hexchat_hook_command (ph, ccmdstr, pri, hjs_callback, helpstr ? chelpstr : " " , hook);
976977
977978 JS_free (context, ccmdstr);
@@ -998,7 +999,7 @@ hjs_hookprint (JSContext *context, unsigned argc, jsval *vp)
998999 char * cevent;
9991000 int pri = HEXCHAT_PRI_NORM;
10001001 hexchat_hook* hexhook;
1001- script_hook* hook = new script_hook ;
1002+ script_hook* hook;
10021003 js_script* script = hjs_script_find (context);
10031004
10041005 if (!JS_ConvertArguments (context, argc, JS_ARGV (context, vp), " So/oi" ,
@@ -1009,6 +1010,7 @@ hjs_hookprint (JSContext *context, unsigned argc, jsval *vp)
10091010 return JS_FALSE;
10101011
10111012 cevent = JSSTRING_TO_CHAR (event);
1013+ hook = new script_hook;
10121014 hexhook = hexchat_hook_print_attrs (ph, cevent, pri, hjs_callback, hook);
10131015 JS_free (context, cevent);
10141016
@@ -1032,7 +1034,7 @@ hjs_hookspecial (JSContext *context, unsigned argc, jsval *vp)
10321034 char * cevent;
10331035 int pri = HEXCHAT_PRI_NORM;
10341036 hexchat_hook* hexhook;
1035- script_hook* hook = new script_hook ;
1037+ script_hook* hook;
10361038 js_script* script = hjs_script_find (context);
10371039
10381040 if (!JS_ConvertArguments (context, argc, JS_ARGV (context, vp), " So/oi" ,
@@ -1045,6 +1047,7 @@ hjs_hookspecial (JSContext *context, unsigned argc, jsval *vp)
10451047 /* This is technically the same as hook_print except that hook_print_attrs won't work with
10461048 * the "special" hooks, so to avoid confusion or adding another hook_print for attrs
10471049 * just create a new function hook_special */
1050+ hook = new script_hook;
10481051 cevent = JSSTRING_TO_CHAR (event);
10491052 hexhook = hexchat_hook_print (ph, cevent, pri, hjs_callback, hook);
10501053 JS_free (context, cevent);
@@ -1069,7 +1072,7 @@ hjs_hookserver (JSContext *context, unsigned argc, jsval *vp)
10691072 char * cserverstr;
10701073 int pri = HEXCHAT_PRI_NORM;
10711074 hexchat_hook* hexhook;
1072- script_hook* hook = new script_hook ;
1075+ script_hook* hook;
10731076 js_script* script = hjs_script_find (context);
10741077
10751078 if (!JS_ConvertArguments (context, argc, JS_ARGV (context, vp), " So/oi" ,
@@ -1079,6 +1082,7 @@ hjs_hookserver (JSContext *context, unsigned argc, jsval *vp)
10791082 if (!JS_ObjectIsFunction (context, funcobj))
10801083 return JS_FALSE;
10811084
1085+ hook = new script_hook;
10821086 cserverstr = JSSTRING_TO_CHAR (serverstr);
10831087 hexhook = hexchat_hook_server_attrs (ph, cserverstr, pri, hjs_callback, hook);
10841088 JS_free (context, cserverstr);
@@ -1101,7 +1105,7 @@ hjs_hooktimer (JSContext *context, unsigned argc, jsval *vp)
11011105 jsval ret;
11021106 int timeout;
11031107 hexchat_hook* hexhook;
1104- script_hook* hook = new script_hook ;
1108+ script_hook* hook;
11051109 js_script* script = hjs_script_find (context);
11061110
11071111 if (!JS_ConvertArguments (context, argc, JS_ARGV (context, vp), " io/o" ,
@@ -1111,6 +1115,7 @@ hjs_hooktimer (JSContext *context, unsigned argc, jsval *vp)
11111115 if (!JS_ObjectIsFunction (context, funcobj))
11121116 return JS_FALSE;
11131117
1118+ hook = new script_hook;
11141119 hexhook = hexchat_hook_timer (ph, timeout, hjs_callback, hook);
11151120
11161121 script->add_hook (hook, HOOK_TIMER, context, funcobj, userdata, hexhook);
@@ -1128,12 +1133,13 @@ hjs_hookunload (JSContext *context, unsigned argc, jsval *vp)
11281133{
11291134 JSObject* funcobj;
11301135 JSObject* userdata = nullptr ;
1131- script_hook* hook = new script_hook ;
1136+ script_hook* hook;
11321137 js_script* script = hjs_script_find (context);
11331138
11341139 if (!JS_ConvertArguments (context, argc, JS_ARGV (context, vp), " o/o" , &funcobj, &userdata))
11351140 return JS_FALSE;
11361141
1142+ hook = new script_hook;
11371143 script->add_hook (hook, HOOK_UNLOAD, context, funcobj, userdata, nullptr );
11381144
11391145 JS_SET_RVAL (context, vp, JSVAL_VOID);
0 commit comments