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 08/05/13 at 13:20:45

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
RevLine 
[65f6d3c]1/**
2 * @file
3 *
4 * @brief Deletes Thread-specific Data Key Previously Returned by keycreate.c
[5cb175bb]5 * @ingroup POSIXAPI
[65f6d3c]6 */
7
[63edcf24]8/*
[b5c9064]9 * COPYRIGHT (c) 1989-2007.
10 * On-Line Applications Research Corporation (OAR).
[feaa007]11 *
[b5c9064]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.
[63edcf24]15 */
16
[f42b726]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[63edcf24]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
[77c330ce]31/*
[63edcf24]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{
[77c330ce]38  POSIX_Keys_Control *the_key;
39  Objects_Locations   location;
[874297f3]40
[63edcf24]41  the_key = _POSIX_Keys_Get( key, &location );
42  switch ( location ) {
[860c34e]43
[63edcf24]44    case OBJECTS_LOCAL:
[77c330ce]45      _POSIX_Keys_Free_memory( the_key );
[63edcf24]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 );
[b5c9064]52      _Objects_Put(&the_key->Object);
[63edcf24]53      return 0;
[860c34e]54
55#if defined(RTEMS_MULTIPROCESSING)
56    case OBJECTS_REMOTE:   /* should never happen */
57#endif
58    case OBJECTS_ERROR:
59      break;
[63edcf24]60  }
[860c34e]61
62  return EINVAL;
[63edcf24]63}
Note: See TracBrowser for help on using the repository browser.