Skip to content

Commit

Permalink
set hook function pointers to null by default, libpd_clear_hooks was …
Browse files Browse the repository at this point in the history
…redundant and wouldn't work anyway if the hooks were set before libpd_init
  • Loading branch information
danomatika committed Dec 18, 2013
1 parent 396494c commit d544e29
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
28 changes: 13 additions & 15 deletions libpd_wrapper/z_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@

#include "z_hooks.h"

void libpd_clear_hooks(void) {
libpd_printhook = NULL;
libpd_banghook = NULL;
libpd_floathook = NULL;
libpd_symbolhook = NULL;
libpd_listhook = NULL;
libpd_messagehook = NULL;
t_libpd_printhook libpd_printhook = NULL;
t_libpd_banghook libpd_banghook = NULL;
t_libpd_floathook libpd_floathook = NULL;
t_libpd_symbolhook libpd_symbolhook = NULL;
t_libpd_listhook libpd_listhook = NULL;
t_libpd_messagehook libpd_messagehook = NULL;

libpd_noteonhook = NULL;
libpd_controlchangehook = NULL;
libpd_programchangehook = NULL;
libpd_pitchbendhook = NULL;
libpd_aftertouchhook = NULL;
libpd_polyaftertouchhook = NULL;
libpd_midibytehook = NULL;
}
t_libpd_noteonhook libpd_noteonhook = NULL;
t_libpd_controlchangehook libpd_controlchangehook = NULL;
t_libpd_programchangehook libpd_programchangehook = NULL;
t_libpd_pitchbendhook libpd_pitchbendhook = NULL;
t_libpd_aftertouchhook libpd_aftertouchhook = NULL;
t_libpd_polyaftertouchhook libpd_polyaftertouchhook = NULL;
t_libpd_midibytehook libpd_midibytehook = NULL;
29 changes: 13 additions & 16 deletions libpd_wrapper/z_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@
// in a separate file so they can be used throughout the libpd_wrapper sources,
// do *not* include this file in a user-facing header

t_libpd_printhook libpd_printhook;
t_libpd_banghook libpd_banghook;
t_libpd_floathook libpd_floathook;
t_libpd_symbolhook libpd_symbolhook;
t_libpd_listhook libpd_listhook;
t_libpd_messagehook libpd_messagehook;
extern t_libpd_printhook libpd_printhook;
extern t_libpd_banghook libpd_banghook;
extern t_libpd_floathook libpd_floathook;
extern t_libpd_symbolhook libpd_symbolhook;
extern t_libpd_listhook libpd_listhook;
extern t_libpd_messagehook libpd_messagehook;

t_libpd_noteonhook libpd_noteonhook;
t_libpd_controlchangehook libpd_controlchangehook;
t_libpd_programchangehook libpd_programchangehook;
t_libpd_pitchbendhook libpd_pitchbendhook;
t_libpd_aftertouchhook libpd_aftertouchhook;
t_libpd_polyaftertouchhook libpd_polyaftertouchhook;
t_libpd_midibytehook libpd_midibytehook;

// sets all hook function pointers to NULL
void libpd_clear_hooks(void);
extern t_libpd_noteonhook libpd_noteonhook;
extern t_libpd_controlchangehook libpd_controlchangehook;
extern t_libpd_programchangehook libpd_programchangehook;
extern t_libpd_pitchbendhook libpd_pitchbendhook;
extern t_libpd_aftertouchhook libpd_aftertouchhook;
extern t_libpd_polyaftertouchhook libpd_polyaftertouchhook;
extern t_libpd_midibytehook libpd_midibytehook;

#endif
1 change: 0 additions & 1 deletion libpd_wrapper/z_libpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ int libpd_init(void) {
static int initialized = 0;
if (initialized) return 0; // only allow init once (for now)
initialized = 1;
libpd_clear_hooks();
signal(SIGFPE, SIG_IGN);
libpd_start_message(32); // allocate array for message assembly
sys_printhook = (t_printhook) libpd_printhook;
Expand Down

0 comments on commit d544e29

Please sign in to comment.