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

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.3 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/score/objectimpl.h>
22#include <rtems/score/wkspace.h>
23
24#include <string.h>
25
26bool _Objects_Set_name(
27  Objects_Information *information,
28  Objects_Control     *the_object,
29  const char          *name
30)
31{
32  size_t                 length;
33  const char            *s;
34
35  s      = name;
36  length = strnlen( name, information->name_length );
37
38#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
39  if ( information->is_string ) {
40    char *d;
41
42    d = _Workspace_Allocate( length + 1 );
43    if ( !d )
44      return false;
45
46    _Workspace_Free( (void *)the_object->name.name_p );
47    the_object->name.name_p = NULL;
48
49    strncpy( d, name, length );
50    d[length] = '\0';
51    the_object->name.name_p = d;
52  } else
53#endif
54  {
55    the_object->name.name_u32 =  _Objects_Build_name(
56      ((0 <= length) ? s[ 0 ] : ' '),
57      ((1 <  length) ? s[ 1 ] : ' '),
58      ((2 <  length) ? s[ 2 ] : ' '),
59      ((3 <  length) ? s[ 3 ] : ' ')
60    );
61
62  }
63
64  return true;
65}
Note: See TracBrowser for help on using the repository browser.