td_ta_delete.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <stdlib.h>
  17. #include "thread_dbP.h"
  18. td_err_e
  19. td_ta_delete (td_thragent_t *ta)
  20. {
  21. LOG ("td_ta_delete");
  22. /* Safety check. */
  23. if (ta == NULL || __td_agent_list == NULL)
  24. return TD_BADTA;
  25. /* Remove the handle from the list. */
  26. if (ta == __td_agent_list->ta)
  27. /* It's the first element of the list. */
  28. __td_agent_list = __td_agent_list->next;
  29. else
  30. {
  31. /* We have to search for it. */
  32. struct agent_list *runp = __td_agent_list;
  33. while (runp->next != NULL && runp->next->ta != ta)
  34. runp = runp->next;
  35. if (runp->next == NULL)
  36. /* It's not a valid descriptor since it is not in the list. */
  37. return TD_BADTA;
  38. runp->next = runp->next->next;
  39. }
  40. /* The handle was allocated in `td_ta_new'. */
  41. free (ta);
  42. return TD_OK;
  43. }