jungerl/zlib changes
Gaspar Chilingarov
nm@REDACTED
Fri Jul 15 16:25:30 CEST 2005
Hi all!
I suggest the following changes to zlib module distributed in jungerl -
--cut--
Index: zlib.erl
===================================================================
RCS file: /cvsroot/jungerl/jungerl/lib/zlib/src/zlib.erl,v
retrieving revision 1.2
diff -c -r1.2 zlib.erl
*** zlib.erl 18 Feb 2004 11:35:29 -0000 1.2
--- zlib.erl 15 Jul 2005 13:26:57 -0000
***************
*** 105,116 ****
%% open a z_stream
open() ->
! ok = load(),
open_port({spawn, zlib_drv}, [binary]).
%% close and release z_stream
close(Z) ->
! port_close(Z).
deflateInit(Z, Level) ->
call(Z, ?DEFLATE_INIT, <<(arg_level(Level)):32>>).
--- 105,121 ----
%% open a z_stream
open() ->
! % ok = load(), %% it is loaded automagically
open_port({spawn, zlib_drv}, [binary]).
%% close and release z_stream
close(Z) ->
! port_close(Z),
! receive
! { 'EXIT', Z, normal } -> ok
! after 0 ->
! ok
! end.
deflateInit(Z, Level) ->
call(Z, ?DEFLATE_INIT, <<(arg_level(Level)):32>>).
--cut--
first of all - imho open_port automatically loads external driver,
and if I leave it load() call, it will fail for subsequent calls to
zlib:compress or zlib:uncompress - because module is already loaded.
seconds change - is to have receive command , which will cleanup port
exit message from process queue, if such message exists.
--
Gaspar Chilingarov
System Administrator
t +37491 419763 (mob)
t +37410 240399 (office)
w www.web.am
i 63174784
e nm@REDACTED
More information about the erlang-questions
mailing list