]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/util/thread_map.c
Merge branches 'pm-core', 'pm-qos', 'pm-domains' and 'pm-opp'
[linux.git] / tools / perf / util / thread_map.c
index 40585f5b7027d1d1eb7c0d78e754c1a7963a74f9..7c3fcc538a705f9df580c33b6444512547b3f453 100644 (file)
@@ -93,7 +93,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
 {
        DIR *proc;
        int max_threads = 32, items, i;
-       char path[256];
+       char path[NAME_MAX + 1 + 6];
        struct dirent *dirent, **namelist = NULL;
        struct thread_map *threads = thread_map__alloc(max_threads);
 
@@ -448,3 +448,25 @@ bool thread_map__has(struct thread_map *threads, pid_t pid)
 
        return false;
 }
+
+int thread_map__remove(struct thread_map *threads, int idx)
+{
+       int i;
+
+       if (threads->nr < 1)
+               return -EINVAL;
+
+       if (idx >= threads->nr)
+               return -EINVAL;
+
+       /*
+        * Free the 'idx' item and shift the rest up.
+        */
+       free(threads->map[idx].comm);
+
+       for (i = idx; i < threads->nr - 1; i++)
+               threads->map[i] = threads->map[i + 1];
+
+       threads->nr--;
+       return 0;
+}