blob: 190239a704a2bb54aca2d77c8a394f29b1d775a4 [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIB_FXL_FILES_UNIQUE_FD_H_
#define LIB_FXL_FILES_UNIQUE_FD_H_
#include "src/lib/fxl/memory/unique_object.h"
namespace fxl {
namespace internal {
struct UniqueFDTraits {
static int InvalidValue() { return -1; }
static bool IsValid(int value) { return value >= 0; }
static void Free(int fd);
};
} // namespace internal
using UniqueFD = UniqueObject<int, internal::UniqueFDTraits>;
} // namespace fxl
#endif // LIB_FXL_FILES_UNIQUE_FD_H_