source: rtems/cpukit/score/src/objectsetname.c @ 632e4306

4.104.115
Last change on this file since 632e4306 was 2a4e8e0, checked in by Joel Sherrill <joel.sherrill@…>, on 06/13/09 at 22:39:39

2009-06-13 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems/rtems/region.h, rtems/src/rtemsobjectgetclassinfo.c, score/src/heapwalk.c, score/src/objectgetnameasstring.c, score/src/objectsetname.c, score/src/timespecdivide.c, score/src/ts64divide.c: Remove include of stdio.h
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/object.h>
18#include <rtems/score/thread.h>
19#include <rtems/score/wkspace.h>
20#include <stdlib.h>
21#include <ctype.h>
22#include <inttypes.h>
23#include <string.h>
24
25
26/*
27 *  This method sets the name of an object based upon a C string.
28 */
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 ) + 1;
41
42  if ( information->is_string ) {
43    char *d;
44
45    d = _Workspace_Allocate( length );
46    if ( !d )
47      return false;
48
49    if ( the_object->name.name_p ) {
50      _Workspace_Free( (void *)the_object->name.name_p );
51      the_object->name.name_p = NULL;
52    }
53
54    strncpy( d, name, length );
55    the_object->name.name_p = d;
56  } else {
57    the_object->name.name_u32 =  _Objects_Build_name(
58      ((0<length) ? s[ 0 ] : ' '),
59      ((1<length) ? s[ 1 ] : ' '),
60      ((2<length) ? s[ 2 ] : ' '),
61      ((3<length) ? s[ 3 ] : ' ')
62    );
63
64  }
65
66  return true;
67}
Note: See TracBrowser for help on using the repository browser.