diff options
author | Peter Lemenkov <lemenkov@redhat.com> | 2016-09-21 17:57:25 +0200 |
---|---|---|
committer | Peter Lemenkov <lemenkov@redhat.com> | 2016-09-21 17:57:25 +0200 |
commit | 95513198dcabd8c6e28b75d0c9966ce9f02c5fcc (patch) | |
tree | 257333187e7c078fa4ba29a8129d25a7a7fb4a73 | |
parent | e7e0e17f74553c038ec3b1608431cf17a5a87646 (diff) | |
download | erlang-sd_notify-95513198dcabd8c6e28b75d0c9966ce9f02c5fcc.tar.gz |
Remove duplicated code
Signed-off-by: Peter Lemenkov <lemenkov@redhat.com>
-rw-r--r-- | c_src/sd_notify.c | 18 | ||||
-rw-r--r-- | 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 <systemd/sd-daemon.h> -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. |