notcurses_stats: copy only stats, not lock #1914

pull/1946/head
nick black 3 years ago
parent fe150bff95
commit ffbafef645
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1066,8 +1066,6 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
ret->margin_l = opts->margin_l;
ret->margin_r = opts->margin_r;
ret->cursory = ret->cursorx = -1;
memset(&ret->stats, 0, sizeof(ret->stats));
memset(&ret->stashed_stats, 0, sizeof(ret->stashed_stats));
reset_stats(&ret->stats.s);
reset_stats(&ret->stashed_stats);
ret->ttyfp = outfp;
@ -1090,7 +1088,6 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
free(ret);
return NULL;
}
memset(&ret->stats.s, 0, sizeof(ret->stats.s));
if(pthread_mutex_init(&ret->stats.lock, NULL)){
pthread_mutex_destroy(&ret->pilelock);
free(ret);

@ -85,7 +85,7 @@ void reset_stats(ncstats* stats){
void notcurses_stats(notcurses* nc, ncstats* stats){
pthread_mutex_lock(&nc->stats.lock);
memcpy(stats, &nc->stats, sizeof(*stats));
memcpy(stats, &nc->stats.s, sizeof(*stats));
pthread_mutex_unlock(&nc->stats.lock);
}

Loading…
Cancel
Save