aboutsummaryrefslogtreecommitdiff
path: root/libc/src/search/hdestroy_r.cpp
blob: e2fda93931f7826ca4e246e578866d24f10dda83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//===-- Implementation of hdestroy_r ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/search/hdestroy_r.h"
#include "src/__support/HashTable/table.h"
#include "src/errno/libc_errno.h"

namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(void, hdestroy_r, (struct hsearch_data * htab)) {
  if (htab == nullptr) {
    libc_errno = EINVAL;
    return;
  }
  internal::HashTable *table =
      static_cast<internal::HashTable *>(htab->__opaque);
  internal::HashTable::deallocate(table);
  htab->__opaque = nullptr;
}

} // namespace LIBC_NAMESPACE