From 63b089e3aa9302206fbfa8260804e501e6483b83 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 12 Nov 2015 21:07:55 -0800 Subject: We can use fclose directly in std::unique_ptr. It turns out the standard explicitly states that if the pointer is null, the deleter function won't be called. So it doesn't matter that fclose(3) doesn't accept null. Change-Id: I10e6e0d62209ec03ac60e673edd46f32ba279a04 --- unique_fd.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'unique_fd.h') diff --git a/unique_fd.h b/unique_fd.h index 98a7c7b67..cc85383f8 100644 --- a/unique_fd.h +++ b/unique_fd.h @@ -59,15 +59,4 @@ class unique_fd { unique_fd& operator=(const unique_fd&) = delete; }; -// Custom deleter for unique_file to avoid fclose(NULL). -struct safe_fclose { - void operator()(FILE *fp) const { - if (fp) { - fclose(fp); - }; - } -}; - -using unique_file = std::unique_ptr; - #endif // UNIQUE_FD_H -- cgit v1.2.3