source: rtems/cpukit/posix/src/keydelete.c @ b5c9064

4.115
Last change on this file since b5c9064 was b5c9064, checked in by Zhongwei Yao <ashi08104@…>, on Aug 5, 2013 at 1:20:45 PM

Unlimited objects support for POSIX keys

This patch enables unlimited model in POSIX key manger and have a decent
runtime on POSIX key searching, adding and deleting operations. Memory
overhead is lower than current implementation when the size of key and key
value becomes big.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Deletes Thread-specific Data Key Previously Returned by keycreate.c
5 * @ingroup POSIXAPI
6 */
7
8/*
9 * COPYRIGHT (c) 1989-2007.
10 * On-Line Applications Research Corporation (OAR).
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <errno.h>
22#include <limits.h>
23#include <pthread.h>
24#include <string.h>
25
26#include <rtems/system.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/posix/key.h>
30
31/*
32 *  17.1.3 Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167
33 */
34int pthread_key_delete(
35  pthread_key_t  key
36)
37{
38  POSIX_Keys_Control *the_key;
39  Objects_Locations   location;
40
41  the_key = _POSIX_Keys_Get( key, &location );
42  switch ( location ) {
43
44    case OBJECTS_LOCAL:
45      _POSIX_Keys_Free_memory( the_key );
46
47      /*
48       *  NOTE:  The destructor is not called and it is the responsibility
49       *         of the application to free the memory.
50       */
51      _POSIX_Keys_Free( the_key );
52      _Objects_Put(&the_key->Object);
53      return 0;
54
55#if defined(RTEMS_MULTIPROCESSING)
56    case OBJECTS_REMOTE:   /* should never happen */
57#endif
58    case OBJECTS_ERROR:
59      break;
60  }
61
62  return EINVAL;
63}
Note: See TracBrowser for help on using the repository browser.