summaryrefslogtreecommitdiff
path: root/src/object.c
diff options
context:
space:
mode:
authorxph <[email protected]>2020-04-09 16:35:28 +0800
committerGitHub <[email protected]>2020-04-09 16:35:28 +0800
commitca7f01d79b3e0a997c771cec298e4ebd65b75809 (patch)
tree3d2c48aae7203b14038ba7b98b500b5343ed7f2a /src/object.c
parentf763f8e7284b0492c5a65ad0abf94ee1963d7dcc (diff)
parentbaa3145bfe61b3330b6a160523cc5470fa5db3a7 (diff)
Merge pull request #1 from RT-Thread/master
sync rtt
Diffstat (limited to 'src/object.c')
-rw-r--r--src/object.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/object.c b/src/object.c
index 70b9a5c04e..4ee2f6a1a1 100644
--- a/src/object.c
+++ b/src/object.c
@@ -240,6 +240,7 @@ void rt_object_init(struct rt_object *object,
const char *name)
{
register rt_base_t temp;
+ struct rt_list_node *node = RT_NULL;
struct rt_object_information *information;
#ifdef RT_USING_MODULE
struct rt_dlmodule *module = dlmodule_self();
@@ -249,11 +250,29 @@ void rt_object_init(struct rt_object *object,
information = rt_object_get_information(type);
RT_ASSERT(information != RT_NULL);
- /* initialize object's parameters */
+ /* check object type to avoid re-initialization */
+
+ /* enter critical */
+ rt_enter_critical();
+ /* try to find object */
+ for (node = information->object_list.next;
+ node != &(information->object_list);
+ node = node->next)
+ {
+ struct rt_object *obj;
+ obj = rt_list_entry(node, struct rt_object, list);
+ if (obj) /* skip warning when disable debug */
+ {
+ RT_ASSERT(obj != object);
+ }
+ }
+ /* leave critical */
+ rt_exit_critical();
+
+ /* initialize object's parameters */
/* set object type to static */
object->type = type | RT_Object_Class_Static;
-
/* copy name */
rt_strncpy(object->name, name, RT_NAME_MAX);