fix mempool init bug.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@178 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
885045ef42
commit
c096268a88
|
@ -108,7 +108,7 @@ rt_err_t rt_mp_init(struct rt_mempool* mp, const char* name, void *start, rt_siz
|
||||||
= (rt_uint8_t*)(block_ptr + (offset + 1) * (block_size + sizeof(rt_uint8_t*)));
|
= (rt_uint8_t*)(block_ptr + (offset + 1) * (block_size + sizeof(rt_uint8_t*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
*(rt_uint8_t**)(block_ptr + offset * (block_size + sizeof(rt_uint8_t*))) = RT_NULL;
|
*(rt_uint8_t**)(block_ptr + (offset - 1) * (block_size + sizeof(rt_uint8_t*))) = RT_NULL;
|
||||||
|
|
||||||
mp->block_list = block_ptr;
|
mp->block_list = block_ptr;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ rt_mp_t rt_mp_create(const char* name, rt_size_t block_count, rt_size_t block_si
|
||||||
= block_ptr + (offset + 1) * (block_size + sizeof(rt_uint8_t*));
|
= block_ptr + (offset + 1) * (block_size + sizeof(rt_uint8_t*));
|
||||||
}
|
}
|
||||||
|
|
||||||
*(rt_uint8_t**)(block_ptr + offset * (block_size + sizeof(rt_uint8_t*))) = RT_NULL;
|
*(rt_uint8_t**)(block_ptr + (offset - 1) * (block_size + sizeof(rt_uint8_t*))) = RT_NULL;
|
||||||
|
|
||||||
mp->block_list = block_ptr;
|
mp->block_list = block_ptr;
|
||||||
|
|
||||||
|
@ -294,7 +294,12 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* memory block is unavailable. */
|
/* memory block is unavailable. */
|
||||||
if (time == 0) return RT_NULL;
|
if (time == 0)
|
||||||
|
{
|
||||||
|
/* enable interrupt */
|
||||||
|
rt_hw_interrupt_enable(level);
|
||||||
|
return RT_NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* get current thread */
|
/* get current thread */
|
||||||
|
@ -335,7 +340,6 @@ void *rt_mp_alloc (rt_mp_t mp, rt_int32_t time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
rt_hw_interrupt_enable(level);
|
rt_hw_interrupt_enable(level);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue