From 95513198dcabd8c6e28b75d0c9966ce9f02c5fcc Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Wed, 21 Sep 2016 17:57:25 +0200 Subject: Remove duplicated code Signed-off-by: Peter Lemenkov --- c_src/sd_notify.c | 18 ------------------ src/sd_notify.erl | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/c_src/sd_notify.c b/c_src/sd_notify.c index 63346b9..bf4e9df 100644 --- a/c_src/sd_notify.c +++ b/c_src/sd_notify.c @@ -24,23 +24,6 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "erl_nif.h" #include -static ERL_NIF_TERM sd_notify_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) -{ - int unset_environment = 0; - enif_get_int(env, argv[0], &unset_environment); - - unsigned int length = 0; - enif_get_list_length(env, argv[1], &length); - - char* state = (char*)enif_alloc(++length); - enif_get_string(env, argv[1], state, length, ERL_NIF_LATIN1); - int result = sd_notify(unset_environment, state); - enif_free(state); - - return enif_make_int(env, result); -} - - static ERL_NIF_TERM sd_pid_notify_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { int pid = 0; @@ -63,7 +46,6 @@ static ERL_NIF_TERM sd_pid_notify_nif(ErlNifEnv* env, int argc, const ERL_NIF_TE static ErlNifFunc nif_funcs[] = { - {"sd_notify", 2, sd_notify_nif}, {"sd_pid_notify", 3, sd_pid_notify_nif}, }; diff --git a/src/sd_notify.erl b/src/sd_notify.erl index 5162340..4610522 100644 --- a/src/sd_notify.erl +++ b/src/sd_notify.erl @@ -51,8 +51,8 @@ init() -> end, erlang:load_nif(filename:join(PrivDir, ?MODULE) ++ "_drv", 0). -sd_notify(_, _) -> - ?nif_stub. +sd_notify(UnsetEnv, Data) -> + sd_pid_notify(0, UnsetEnv, Data). sd_pid_notify(_, _, _) -> ?nif_stub. -- cgit v1.2.1