source: rtems/cpukit/score/src/objectsetname.c @ e6f7f81

4.115
Last change on this file since e6f7f81 was 8396c18e, checked in by Mathew Kallada <matkallada@…>, on 11/30/12 at 02:01:26

Score misc: Clean up Doxygen #8 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/7970221

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Objects Name
5 * @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
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#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/object.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25#include <stdlib.h>
26#include <ctype.h>
27#include <inttypes.h>
28#include <string.h>
29
30bool _Objects_Set_name(
31  Objects_Information *information,
32  Objects_Control     *the_object,
33  const char          *name
34)
35{
36  size_t                 length;
37  const char            *s;
38
39  s      = name;
40  length = strnlen( name, information->name_length );
41
42#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
43  if ( information->is_string ) {
44    char *d;
45
46    d = _Workspace_Allocate( length + 1 );
47    if ( !d )
48      return false;
49
50    _Workspace_Free( (void *)the_object->name.name_p );
51    the_object->name.name_p = NULL;
52
53    strncpy( d, name, length );
54    d[length] = '\0';
55    the_object->name.name_p = d;
56  } else
57#endif
58  {
59    the_object->name.name_u32 =  _Objects_Build_name(
60      ((0 <= length) ? s[ 0 ] : ' '),
61      ((1 <  length) ? s[ 1 ] : ' '),
62      ((2 <  length) ? s[ 2 ] : ' '),
63      ((3 <  length) ? s[ 3 ] : ' ')
64    );
65
66  }
67
68  return true;
69}
Note: See TracBrowser for help on using the repository browser.