b3a319d528
Introduce and use the thread_map__nr() function to protect a possible NULL pointer dereference and cleanup the code a bit. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1362987798-24969-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
30 lines
722 B
C
30 lines
722 B
C
#ifndef __PERF_THREAD_MAP_H
|
|
#define __PERF_THREAD_MAP_H
|
|
|
|
#include <sys/types.h>
|
|
#include <stdio.h>
|
|
|
|
struct thread_map {
|
|
int nr;
|
|
pid_t map[];
|
|
};
|
|
|
|
struct thread_map *thread_map__new_by_pid(pid_t pid);
|
|
struct thread_map *thread_map__new_by_tid(pid_t tid);
|
|
struct thread_map *thread_map__new_by_uid(uid_t uid);
|
|
struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
|
|
|
|
struct thread_map *thread_map__new_str(const char *pid,
|
|
const char *tid, uid_t uid);
|
|
|
|
void thread_map__delete(struct thread_map *threads);
|
|
|
|
size_t thread_map__fprintf(struct thread_map *threads, FILE *fp);
|
|
|
|
static inline int thread_map__nr(struct thread_map *threads)
|
|
{
|
|
return threads ? threads->nr : 1;
|
|
}
|
|
|
|
#endif /* __PERF_THREAD_MAP_H */
|