source: rtems/cpukit/score/src/objectsetname.c @ 9c9c6a9

5
Last change on this file since 9c9c6a9 was 9c9c6a9, checked in by Sebastian Huber <sebastian.huber@…>, on 11/21/18 at 16:30:52

score: Remove Objects_Information::is_string

Use Objects_Information::name_length to store this information.

Update #3621.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Objects Name
5 * @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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.org/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  const Objects_Information *information,
28  Objects_Control           *the_object,
29  const char                *name
30)
31{
32  if ( _Objects_Has_string_name( information ) ) {
33    size_t  length;
34    char   *dup;
35
36    length = strnlen( name, information->name_length );
37    dup = _Workspace_String_duplicate( name, length );
38    if ( dup == NULL ) {
39      return false;
40    }
41
42    the_object->name.name_p = dup;
43  } else {
44    char c[ 4 ];
45    size_t i;
46
47    memset( c, ' ', sizeof( c ) );
48
49    for ( i = 0; i < 4; ++i ) {
50      if ( name[ i ] == '\0') {
51        break;
52      }
53
54      c[ i ] = name[ i ];
55    }
56
57    the_object->name.name_u32 =
58      _Objects_Build_name( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );
59  }
60
61  return true;
62}
Note: See TracBrowser for help on using the repository browser.