pike.git
/
src
/
modules
/
Gz
/
zlibmod.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/Gz/zlibmod.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: zlibmod.c,v 1.
85
2009/
04
/
26
18
:
33
:
18
peter
Exp $
+
|| $Id: zlibmod.c,v 1.
86
2009/
08
/
28
13
:
30
:
54
mast
Exp $
*/ #include "global.h" #include "zlib_machine.h" #include "module.h" #include "program.h" #include "module_support.h" #if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ) #undef HAVE_ZLIB_H
pike.git/src/modules/Gz/zlibmod.c:222:
default: if(THIS->gz.msg) Pike_error("Failed to initialize Gz.deflate: %s\n",THIS->gz.msg); else Pike_error("Failed to initialize Gz.deflate (%d).\n", tmp); } }
+
static void do_mt_unlock (PIKE_MUTEX_T *lock)
+
{
+
mt_unlock (lock);
+
}
+
static int do_deflate(dynamic_buffer *buf, struct zipper *this, int flush) { int ret=0;
-
+
ONERROR uwp;
THREADS_ALLOW(); mt_lock(& this->lock); THREADS_DISALLOW();
-
+
SET_ONERROR (uwp, do_mt_unlock, &this->lock);
+
if(!this->gz.state) ret=Z_STREAM_ERROR; else do { this->gz.next_out=(Bytef *)low_make_buf_space( /* recommended by the zlib people */ (this->gz.avail_out = this->gz.avail_in ? this->gz.avail_in+this->gz.avail_in/1000+42 :
pike.git/src/modules/Gz/zlibmod.c:255:
ret=deflate(& this->gz, flush); THREADS_DISALLOW(); /* Absorb any unused space /Hubbe */ low_make_buf_space(-((ptrdiff_t)this->gz.avail_out), buf); if(ret == Z_BUF_ERROR) ret=Z_OK; } while (ret==Z_OK && (this->gz.avail_in || !this->gz.avail_out));
-
mt
_
unlock(&
this->lock
);
+
CALL
_
AND_UNSET_ONERROR
(
uwp
);
return ret; } void zlibmod_pack(struct pike_string *data, dynamic_buffer *buf, int level, int strategy, int wbits) { struct zipper z; int ret; if(level < Z_NO_COMPRESSION ||
pike.git/src/modules/Gz/zlibmod.c:631:
else Pike_error("Failed to initialize Gz.inflate (%d).\n", tmp); } } static int do_inflate(dynamic_buffer *buf, struct zipper *this, int flush) { int fail=0;
+
ONERROR uwp;
+
THREADS_ALLOW(); mt_lock(& this->lock); THREADS_DISALLOW();
-
+
SET_ONERROR (uwp, do_mt_unlock, &this->lock);
+
if(!this->gz.state) { fail=Z_STREAM_ERROR; }else{ #if 0 static int fnord=0; fnord++; #endif do
pike.git/src/modules/Gz/zlibmod.c:682:
if(ret == Z_BUF_ERROR) ret=Z_OK; if(ret != Z_OK) { fail=ret; break; } } while(!this->gz.avail_out || flush==Z_FINISH || this->gz.avail_in); }
-
mt
_
unlock(&
this->lock
);
+
+
CALL
_
AND_UNSET_ONERROR
(
uwp
);
return fail; } void zlibmod_unpack(struct pike_string *data, dynamic_buffer *buf, int raw) { struct zipper z; int ret; MEMSET(&z, 0, sizeof(z)); z.gz.zalloc = Z_NULL;