summaryrefslogtreecommitdiff
path: root/src/libmach_amd64/darwin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmach_amd64/darwin.c')
-rw-r--r--src/libmach_amd64/darwin.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/libmach_amd64/darwin.c b/src/libmach_amd64/darwin.c
index 4adf03b1a..00cf7171f 100644
--- a/src/libmach_amd64/darwin.c
+++ b/src/libmach_amd64/darwin.c
@@ -341,11 +341,10 @@ attachproc(int id, Fhdr *fp)
// Return list of ids for threads in id.
int
-procthreadpids(int id, int **thread)
+procthreadpids(int id, int *out, int nout)
{
Thread *t;
int i, n, pid;
- int *out;
t = idtotable(id);
if(t == nil)
@@ -353,17 +352,13 @@ procthreadpids(int id, int **thread)
pid = t->pid;
addpid(pid, 1); // force refresh of thread list
n = 0;
- for(i=0; i<nthr; i++)
- if(thr[i].pid == pid)
+ for(i=0; i<nthr; i++) {
+ if(thr[i].pid == pid) {
+ if(n < nout)
+ out[n] = -(i+1);
n++;
- out = malloc(n*sizeof out[0]);
- if(out == nil)
- return -1;
- n = 0;
- for(i=0; i<nthr; i++)
- if(thr[i].pid == pid)
- out[n++] = -(i+1);
- *thread = out;
+ }
+ }
return n;
}