Skip to content
Snippets Groups Projects
Commit 104730b3 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

fixed memory leak in Pipe.pipe [bug 65]

Rev: src/modules/Pipe/pipe.c:1.43
parent 41dc863d
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <fcntl.h> #include <fcntl.h>
RCSID("$Id: pipe.c,v 1.42 2000/08/19 11:18:12 grubba Exp $"); RCSID("$Id: pipe.c,v 1.43 2000/08/28 22:13:09 hubbe Exp $");
#include "threads.h" #include "threads.h"
#include "stralloc.h" #include "stralloc.h"
...@@ -220,6 +220,8 @@ static INLINE struct input *new_input(void) ...@@ -220,6 +220,8 @@ static INLINE struct input *new_input(void)
/* Free an input struct and all that it stands for */ /* Free an input struct and all that it stands for */
static INLINE void free_input(struct input *i) static INLINE void free_input(struct input *i)
{ {
debug_malloc_touch(i);
ninputs--; ninputs--;
switch (i->type) switch (i->type)
{ {
...@@ -300,6 +302,8 @@ static INLINE int append_buffer(struct pike_string *s) ...@@ -300,6 +302,8 @@ static INLINE int append_buffer(struct pike_string *s)
{ {
struct buffer *b; struct buffer *b;
debug_malloc_touch(s);
if(THIS->fd!= -1) if(THIS->fd!= -1)
{ {
fd_lseek(THIS->fd, THIS->pos, SEEK_SET); fd_lseek(THIS->fd, THIS->pos, SEEK_SET);
...@@ -576,6 +580,8 @@ static INLINE void output_finish(struct object *obj) ...@@ -576,6 +580,8 @@ static INLINE void output_finish(struct object *obj)
struct output *o, *oi; struct output *o, *oi;
struct object *obji; struct object *obji;
debug_malloc_touch(obj);
o=(struct output *)(obj->storage); o=(struct output *)(obj->storage);
if (o->obj) if (o->obj)
...@@ -629,6 +635,8 @@ static INLINE void output_try_write_some(struct object *obj) ...@@ -629,6 +635,8 @@ static INLINE void output_try_write_some(struct object *obj)
size_t len; size_t len;
INT_TYPE ret; INT_TYPE ret;
debug_malloc_touch(obj);
out=(struct output*)(obj->storage); out=(struct output*)(obj->storage);
#ifdef INSISTANT_WRITE #ifdef INSISTANT_WRITE
...@@ -944,7 +952,7 @@ static void pipe_output(INT32 args) ...@@ -944,7 +952,7 @@ static void pipe_output(INT32 args)
else else
o->pos=THIS->pos; o->pos=THIS->pos;
ref_push_object(obj); push_object(obj); /* Ok, David, this is probably correct, but I dare you to explain why :) */
apply(o->obj,"set_id",1); apply(o->obj,"set_id",1);
pop_stack(); pop_stack();
...@@ -1032,6 +1040,7 @@ static void pipe_write_output_callback(INT32 args) ...@@ -1032,6 +1040,7 @@ static void pipe_write_output_callback(INT32 args)
if(sp[-args].u.object->prog != output_program) if(sp[-args].u.object->prog != output_program)
error("Illegal argument to pipe->write_output_callback\n"); error("Illegal argument to pipe->write_output_callback\n");
debug_malloc_touch(sp[-args].u.object);
output_try_write_some(sp[-args].u.object); output_try_write_some(sp[-args].u.object);
pop_n_elems(args-1); pop_n_elems(args-1);
} }
...@@ -1134,6 +1143,9 @@ void close_and_free_everything(struct object *thisobj,struct pipe *p) ...@@ -1134,6 +1143,9 @@ void close_and_free_everything(struct object *thisobj,struct pipe *p)
struct output *o; struct output *o;
struct object *obj; struct object *obj;
debug_malloc_touch(thisobj);
debug_malloc_touch(p);
if(p->done){ if(p->done){
return; return;
} }
...@@ -1195,6 +1207,8 @@ void close_and_free_everything(struct object *thisobj,struct pipe *p) ...@@ -1195,6 +1207,8 @@ void close_and_free_everything(struct object *thisobj,struct pipe *p)
static void init_pipe_struct(struct object *o) static void init_pipe_struct(struct object *o)
{ {
debug_malloc_touch(o);
THIS->firstbuffer=THIS->lastbuffer=NULL; THIS->firstbuffer=THIS->lastbuffer=NULL;
THIS->firstinput=THIS->lastinput=NULL; THIS->firstinput=THIS->lastinput=NULL;
THIS->firstoutput=NULL; THIS->firstoutput=NULL;
...@@ -1220,7 +1234,9 @@ static void exit_output_struct(struct object *obj) ...@@ -1220,7 +1234,9 @@ static void exit_output_struct(struct object *obj)
{ {
struct output *o; struct output *o;
debug_malloc_touch(obj);
o=(struct output *)(Pike_fp->current_storage); o=(struct output *)(Pike_fp->current_storage);
if (o->obj) if (o->obj)
{ {
if(o->obj->prog) if(o->obj->prog)
...@@ -1249,6 +1265,7 @@ static void exit_output_struct(struct object *obj) ...@@ -1249,6 +1265,7 @@ static void exit_output_struct(struct object *obj)
static void init_output_struct(struct object *ob) static void init_output_struct(struct object *ob)
{ {
struct output *o; struct output *o;
debug_malloc_touch(ob);
o=(struct output *)(Pike_fp->current_storage); o=(struct output *)(Pike_fp->current_storage);
o->obj=0; o->obj=0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment