summaryrefslogtreecommitdiff
path: root/linuxthreads_db/td_ta_delete.c
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db/td_ta_delete.c')
-rw-r--r--linuxthreads_db/td_ta_delete.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/linuxthreads_db/td_ta_delete.c b/linuxthreads_db/td_ta_delete.c
index a8031f2d27..e983577665 100644
--- a/linuxthreads_db/td_ta_delete.c
+++ b/linuxthreads_db/td_ta_delete.c
@@ -28,6 +28,29 @@ td_ta_delete (td_thragent_t *ta)
{
LOG (__FUNCTION__);
+ /* Safety check. */
+ if (ta == NULL || __td_agent_list == NULL)
+ return TD_BADTA;
+
+ /* Remove the handle from the list. */
+ if (ta == __td_agent_list->ta)
+ /* It's the first element of the list. */
+ __td_agent_list = __td_agent_list->next;
+ else
+ {
+ /* We have to search for it. */
+ struct agent_list *runp = __td_agent_list;
+
+ while (runp->next != NULL && runp->next->ta != ta)
+ runp = runp->next;
+
+ if (runp->next == NULL)
+ /* It's not a valid decriptor since it is not in the list. */
+ return TD_BADTA;
+
+ runp->next = runp->next->next;
+ }
+
/* The handle was allocated in `td_ta_new'. */
free (ta);