summaryrefslogtreecommitdiff
path: root/tempfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'tempfile.c')
-rw-r--r--tempfile.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tempfile.c b/tempfile.c
index e655e28477..11bda824cf 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -55,14 +55,16 @@
#include "tempfile.h"
#include "sigchain.h"
-static struct tempfile *volatile tempfile_list;
+static VOLATILE_LIST_HEAD(tempfile_list);
static void remove_tempfiles(int in_signal_handler)
{
pid_t me = getpid();
- struct tempfile *volatile p;
+ volatile struct volatile_list_head *pos;
+
+ list_for_each(pos, &tempfile_list) {
+ struct tempfile *p = list_entry(pos, struct tempfile, list);
- for (p = tempfile_list; p; p = p->next) {
if (!is_tempfile_active(p) || p->owner != me)
continue;
@@ -95,7 +97,7 @@ static void remove_tempfiles_on_signal(int signo)
*/
static void prepare_tempfile_object(struct tempfile *tempfile)
{
- if (!tempfile_list) {
+ if (volatile_list_empty(&tempfile_list)) {
/* One-time initialization */
sigchain_push_common(remove_tempfiles_on_signal);
atexit(remove_tempfiles_on_exit);
@@ -110,8 +112,7 @@ static void prepare_tempfile_object(struct tempfile *tempfile)
tempfile->active = 0;
tempfile->owner = 0;
strbuf_init(&tempfile->filename, 0);
- tempfile->next = tempfile_list;
- tempfile_list = tempfile;
+ 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. */