- if (volatile_list_empty(&tempfile_list)) {
- /* One-time initialization */
- sigchain_push_common(remove_tempfiles_on_signal);
- atexit(remove_tempfiles_on_exit);
- }
-
- if (is_tempfile_active(tempfile))
- BUG("prepare_tempfile_object called for active object");
- if (!tempfile->on_list) {
- /* Initialize *tempfile and add it to tempfile_list: */
- tempfile->fd = -1;
- tempfile->fp = NULL;
- tempfile->active = 0;
- tempfile->owner = 0;
- strbuf_init(&tempfile->filename, 0);
- volatile_list_add(&tempfile->list, &tempfile_list);
- tempfile->on_list = 1;
- } else if (tempfile->filename.len) {
- /* This shouldn't happen, but better safe than sorry. */
- BUG("prepare_tempfile_object called for improperly-reset object");
- }
+ tempfile->fd = -1;
+ tempfile->fp = NULL;
+ tempfile->active = 0;
+ tempfile->owner = 0;
+ INIT_LIST_HEAD(&tempfile->list);
+ strbuf_init(&tempfile->filename, 0);