| 2814 | } |
| 2815 | |
| 2816 | int |
| 2817 | prof_thread_name_set(tsd_t *tsd, const char *thread_name) { |
| 2818 | prof_tdata_t *tdata; |
| 2819 | unsigned i; |
| 2820 | char *s; |
| 2821 | |
| 2822 | tdata = prof_tdata_get(tsd, true); |
| 2823 | if (tdata == NULL) { |
| 2824 | return EAGAIN; |
| 2825 | } |
| 2826 | |
| 2827 | /* Validate input. */ |
| 2828 | if (thread_name == NULL) { |
| 2829 | return EFAULT; |
| 2830 | } |
| 2831 | for (i = 0; thread_name[i] != '\0'; i++) { |
| 2832 | char c = thread_name[i]; |
| 2833 | if (!isgraph(c) && !isblank(c)) { |
| 2834 | return EFAULT; |
| 2835 | } |
| 2836 | } |
| 2837 | |
| 2838 | s = prof_thread_name_alloc(tsd_tsdn(tsd), thread_name); |
| 2839 | if (s == NULL) { |
| 2840 | return EAGAIN; |
| 2841 | } |
| 2842 | |
| 2843 | if (tdata->thread_name != NULL) { |
| 2844 | idalloctm(tsd_tsdn(tsd), tdata->thread_name, NULL, NULL, true, |
| 2845 | true); |
| 2846 | tdata->thread_name = NULL; |
| 2847 | } |
| 2848 | if (strlen(s) > 0) { |
| 2849 | tdata->thread_name = s; |
| 2850 | } |
| 2851 | return 0; |
| 2852 | } |
| 2853 | |
| 2854 | bool |
| 2855 | prof_thread_active_get(tsd_t *tsd) { |
no test coverage detected