static void gst_media_descriptor_finalize (GstMediaDescriptor * self) { if (self->filenode) free_filenode (self->filenode); G_OBJECT_CLASS (gst_media_descriptor_parent_class)->finalize (G_OBJECT (self)); }
int file_close(STRING * sval) { FILE_NODE *p; FILE_NODE *q = 0; /* trails p */ FILE_NODE *hold; char *name = sval->str; int retval = -1; p = file_list; while (p) { if (strcmp(name, p->name->str) == 0) { /* found */ /* Remove it from the list first because we might be called again if an error occurs leading to an infinite loop. Note that we don't have to consider the list corruption caused by a recursive call because it will never return. */ if (q == 0) file_list = p->link; else q->link = p->link; switch (p->type) { case F_TRUNC: case F_APPEND: if (fclose((FILE *) p->ptr) != 0) { close_error(p); } retval = 0; break; case PIPE_OUT: if (fclose((FILE *) p->ptr) != 0) { close_error(p); } #ifdef HAVE_REAL_PIPES retval = wait_for(p->pid); #endif #ifdef HAVE_FAKE_PIPES retval = close_fake_outpipe(p->name->str, p->pid); #endif break; case F_IN: FINclose((FIN *) p->ptr); retval = 0; break; case PIPE_IN: FINclose((FIN *) p->ptr); #ifdef HAVE_REAL_PIPES retval = wait_for(p->pid); #endif #ifdef HAVE_FAKE_PIPES { char xbuff[100]; unlink(tmp_file_name(p->pid, xbuff)); retval = p->inpipe_exit; } #endif break; } hold = p; p = p->link; free_filenode(hold); } else { q = p; p = p->link; } } return retval; }
/* * Find a file on file_list. Outputs return a FILE*, while inputs return FIN*. */ PTR file_find(STRING * sval, int type) { PTR result = 0; FILE_NODE *p; FILE_NODE *q; char *name = sval->str; TRACE(("file_find(%s, %d)\n", name, type)); for (q = 0, p = file_list; p != 0; q = p, p = p->link) { /* search is by name and type */ if (strcmp(name, p->name->str) == 0 && (p->type == type || /* no distinction between F_APPEND and F_TRUNC here */ (p->type >= F_APPEND && type >= F_APPEND))) { if (q != 0) { /* delete from list for move to front */ q->link = p->link; } break; /* while loop */ } } if (!p) { /* open a new one */ p = alloc_filenode(); switch (p->type = (short) type) { case F_TRUNC: if (!(p->ptr = (PTR) tfopen(name, BinMode2("wb", "w")))) output_failed(name); break; case F_APPEND: if (!(p->ptr = (PTR) tfopen(name, BinMode2("ab", "a")))) output_failed(name); break; case F_IN: p->ptr = (PTR) FINopen(name, 0); break; case PIPE_OUT: case PIPE_IN: #if defined(HAVE_REAL_PIPES) || defined(HAVE_FAKE_PIPES) if (!(p->ptr = get_pipe(name, type, &p->pid))) { if (type == PIPE_OUT) output_failed(name); } #else rt_error("pipes not supported"); #endif break; #ifdef DEBUG default: bozo("bad file type"); #endif } } else if (p->ptr == 0 && type == F_IN) { p->ptr = (PTR) FINopen(name, 0); } /* put p at the front of the list */ if (p->ptr == 0) { free_filenode(p); } else { if (p != file_list) { p->link = file_list; file_list = p; } /* successful open */ p->name = sval; sval->ref_cnt++; TRACE(("-> %p\n", p->ptr)); result = p->ptr; } return result; }