diff options
| author | qiuyiuestc <[email protected]> | 2010-10-28 01:21:47 +0000 |
|---|---|---|
| committer | qiuyiuestc <[email protected]> | 2010-10-28 01:21:47 +0000 |
| commit | fb7d4122fc97be364cf2ce76380b0e5465aba7eb (patch) | |
| tree | 5149aa8116873baaeb7b8e9cb7160a5011aa10bd /src/object.c | |
| parent | a6f06d24cfec32dddee27a1ce61920fc4007d68a (diff) | |
implement module memory allocator
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1030 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src/object.c')
| -rw-r--r-- | src/object.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/object.c b/src/object.c index 2b8ccb62d3..c992f0fe04 100644 --- a/src/object.c +++ b/src/object.c @@ -14,6 +14,7 @@ * 2006-05-18 Bernard fix the object init bug * 2006-08-03 Bernard add hook support * 2007-01-28 Bernard rename RT_OBJECT_Class_Static to RT_Object_Class_Static + * 2010-10-26 yi.qiu add module support in rt_object_allocate and rt_object_free */ #include <rtthread.h> @@ -270,12 +271,23 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char* name) /* no memory can be allocated */ return RT_NULL; } - + /* init object's parameters */ /* set object type */ object->type = type; + /* set object flag */ + object->flag = 0; + +#ifdef RT_USING_MODULE + if(rt_module_self() != RT_NULL) + { + object->module_id = (void*)rt_module_self(); + object->flag |= RT_OBJECT_FLAG_MODULE; + } +#endif + /* copy name */ for (temp = 0; temp < RT_NAME_MAX; temp ++) { @@ -325,6 +337,12 @@ void rt_object_delete(rt_object_t object) /* unlock interrupt */ rt_hw_interrupt_enable(temp); +#ifdef RT_USING_MODULE + if(object->flag & RT_OBJECT_FLAG_MODULE) + rt_module_free((rt_module_t)object->module_id, object); + else +#endif + /* free the memory of object */ rt_free(object); } |
