[PATCH] capture: change to use malloc/vs/rtems_workspace_alloc.
Chris Johns
chrisj at rtems.org
Thu Jul 24 23:01:34 UTC 2014
On 24/07/2014 11:54 pm, Jennifer Averett wrote:
> ---
> cpukit/libmisc/capture/capture.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/cpukit/libmisc/capture/capture.c b/cpukit/libmisc/capture/capture.c
> index 9ec07b8..1fac4a0 100644
> --- a/cpukit/libmisc/capture/capture.c
> +++ b/cpukit/libmisc/capture/capture.c
> @@ -339,9 +339,9 @@ rtems_capture_create_control (rtems_name name, rtems_id id)
This one is ok.
>
> if (control == NULL)
> {
> - bool ok = rtems_workspace_allocate (sizeof (*control), (void **) &control);
> + control = malloc (sizeof (*control));
>
> - if (!ok)
> + if (control == NULL)
> {
> capture_flags |= RTEMS_CAPTURE_NO_MEMORY;
> return NULL;
> @@ -386,11 +386,10 @@ rtems_capture_create_capture_task (rtems_tcb* new_task)
> rtems_capture_control_t* control;
> rtems_name name;
> rtems_capture_time_t time;
> - bool ok;
>
> - ok = rtems_workspace_allocate (sizeof (*task), (void **) &task);
> + task = malloc (sizeof (*task));
Can malloc be called while in a user extension such as the context switch ?
Calls to this function happen during a context switch as the capture
engine discovers existing tasks.
When this code was written calling malloc crashed the target during a
context switch.
Chris
>
> - if (!ok)
> + if (task == NULL)
> {
> capture_flags |= RTEMS_CAPTURE_NO_MEMORY;
> return NULL;
> @@ -480,7 +479,7 @@ rtems_capture_destroy_capture_task (rtems_capture_task_t* task)
>
> rtems_interrupt_lock_release (&capture_lock, &lock_context);
>
> - rtems_workspace_free (task);
> + free (task);
> }
> }
>
> @@ -1027,7 +1026,7 @@ rtems_capture_close (void)
> {
> rtems_capture_task_t* delete = task;
> task = task->forw;
> - rtems_workspace_free (delete);
> + free (delete);
> }
>
> capture_tasks = NULL;
> @@ -1038,7 +1037,7 @@ rtems_capture_close (void)
> {
> rtems_capture_control_t* delete = control;
> control = control->next;
> - rtems_workspace_free (delete);
> + free (delete);
> }
>
> capture_controls = NULL;
> @@ -1216,7 +1215,7 @@ rtems_capture_watch_del (rtems_name name, rtems_id id)
>
> rtems_interrupt_lock_release (&capture_lock, &lock_context);
>
> - rtems_workspace_free (control);
> + free (control);
>
> control = *prev_control;
>
>
More information about the devel
mailing list