diff options
| author | Bernard Xiong <[email protected]> | 2019-05-20 20:33:07 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-05-20 20:33:07 +0800 |
| commit | b2ae7d72f923e1638f72d8eba5c2131389b741b0 (patch) | |
| tree | ab526e2e216f5f656b9c6a53221382d07c7bac2e /src/object.c | |
| parent | d778c9df25cbbd8e202a0133453e4c8b8e179eff (diff) | |
| parent | 35eff9a85dd1e922f98d36deed84bdfb3c8319f7 (diff) | |
Merge pull request #2703 from armink/lts-v3.1.x
Lts v3.1.x
Diffstat (limited to 'src/object.c')
| -rw-r--r-- | src/object.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/object.c b/src/object.c index 70b9a5c04e..e85737ce8f 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,26 @@ 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); + 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); |
