td_ta_delete.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Detach to target process.
  2. Copyright (C) 1999, 2001 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include <stdlib.h>
  18. #include "thread_dbP.h"
  19. td_err_e
  20. td_ta_delete (td_thragent_t *ta)
  21. {
  22. LOG ("td_ta_delete");
  23. /* Safety check. */
  24. if (ta == NULL || __td_agent_list == NULL)
  25. return TD_BADTA;
  26. /* Remove the handle from the list. */
  27. if (ta == __td_agent_list->ta)
  28. /* It's the first element of the list. */
  29. __td_agent_list = __td_agent_list->next;
  30. else
  31. {
  32. /* We have to search for it. */
  33. struct agent_list *runp = __td_agent_list;
  34. while (runp->next != NULL && runp->next->ta != ta)
  35. runp = runp->next;
  36. if (runp->next == NULL)
  37. /* It's not a valid descriptor since it is not in the list. */
  38. return TD_BADTA;
  39. runp->next = runp->next->next;
  40. }
  41. /* The handle was allocated in `td_ta_new'. */
  42. free (ta);
  43. return TD_OK;
  44. }