Add target_remove_tid

This commit is contained in:
Alexander Batalov 2023-09-02 17:47:43 +03:00
parent 29e81f3bf4
commit fe47d88035
2 changed files with 47 additions and 0 deletions

View File

@ -291,6 +291,52 @@ int target_remove(int pid)
return 0; return 0;
} }
// 0x49BC3C
int target_remove_tid(int pid, int tid)
{
TargetNode* node;
TargetSubNode* subnode;
TargetSubNode* subnode_next;
node = targetlist.tail;
while (node != NULL) {
if (node->subnode.field_0 == pid) {
break;
}
node = node->next;
}
if (node == NULL) {
return -1;
}
if (node->subnode.field_4 == tid) {
subnode_next = node->subnode.next;
if (subnode_next != NULL) {
memcpy(&(node->subnode), subnode_next, sizeof(TargetSubNode));
internal_free(subnode_next);
} else {
target_remove(pid);
}
// FIXME: Should probably return 0 here.
} else {
subnode = &(node->subnode);
while (subnode != NULL) {
subnode_next = subnode->next;
if (subnode_next->field_4 == tid) {
subnode->next = subnode_next->next;
internal_free(subnode_next);
return 0;
}
subnode = subnode_next;
}
}
return -1;
}
// 0x49BCBC // 0x49BCBC
int target_remove_all() int target_remove_all()
{ {

View File

@ -57,6 +57,7 @@ int target_save(int pid);
int target_load(int pid, TargetSubNode** subnode_ptr); int target_load(int pid, TargetSubNode** subnode_ptr);
int target_find_free_subnode(TargetSubNode** subnode_ptr); int target_find_free_subnode(TargetSubNode** subnode_ptr);
int target_remove(int pid); int target_remove(int pid);
int target_remove_tid(int pid, int tid);
int target_remove_all(); int target_remove_all();
int target_ptr(int pid, TargetSubNode** subnode_ptr); int target_ptr(int pid, TargetSubNode** subnode_ptr);
int target_tid_ptr(int pid, int tid, TargetSubNode** subnode_ptr); int target_tid_ptr(int pid, int tid, TargetSubNode** subnode_ptr);