mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
ncplot: destroy ncplane on all paths #627
This commit is contained in:
parent
dca9db9687
commit
14cd8311e3
@ -27,18 +27,22 @@ class ncppplot {
|
|||||||
// if miny == maxy (enabling domain detection), they both must be equal to 0
|
// if miny == maxy (enabling domain detection), they both must be equal to 0
|
||||||
if(miny == maxy && miny){
|
if(miny == maxy && miny){
|
||||||
//logerror(nc, "Supplied non-zero domain detection param %d\n", miny);
|
//logerror(nc, "Supplied non-zero domain detection param %d\n", miny);
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(opts->rangex < 0){
|
if(opts->rangex < 0){
|
||||||
//logerror(nc, "Supplied negative independent range %d\n", opts->rangex);
|
//logerror(nc, "Supplied negative independent range %d\n", opts->rangex);
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(maxy < miny){
|
if(maxy < miny){
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// DETECTMAXONLY can't be used without domain detection
|
// DETECTMAXONLY can't be used without domain detection
|
||||||
if(opts->flags & NCPLOT_OPTION_DETECTMAXONLY && (miny != maxy)){
|
if(opts->flags & NCPLOT_OPTION_DETECTMAXONLY && (miny != maxy)){
|
||||||
//logerror(nc, "Supplied DETECTMAXONLY without domain detection");
|
//logerror(nc, "Supplied DETECTMAXONLY without domain detection");
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ncblitter_e blitter = opts ? opts->gridtype : NCBLIT_DEFAULT;
|
ncblitter_e blitter = opts ? opts->gridtype : NCBLIT_DEFAULT;
|
||||||
@ -53,11 +57,13 @@ class ncppplot {
|
|||||||
auto bset = lookup_blitset(notcurses_canutf8(ncplane_notcurses(n)),
|
auto bset = lookup_blitset(notcurses_canutf8(ncplane_notcurses(n)),
|
||||||
blitter, degrade_blitter);
|
blitter, degrade_blitter);
|
||||||
if(bset == nullptr){
|
if(bset == nullptr){
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int sdimy, sdimx;
|
int sdimy, sdimx;
|
||||||
ncplane_dim_yx(n, &sdimy, &sdimx);
|
ncplane_dim_yx(n, &sdimy, &sdimx);
|
||||||
if(sdimx <= 0){
|
if(sdimx <= 0){
|
||||||
|
ncplane_destroy(n);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int dimx = sdimx;
|
int dimx = sdimx;
|
||||||
@ -85,7 +91,10 @@ class ncppplot {
|
|||||||
}
|
}
|
||||||
size_t slotsize = sizeof(*ncpp->slots) * ncpp->slotcount;
|
size_t slotsize = sizeof(*ncpp->slots) * ncpp->slotcount;
|
||||||
ncpp->slots = static_cast<T*>(malloc(slotsize));
|
ncpp->slots = static_cast<T*>(malloc(slotsize));
|
||||||
if(ncpp->slots){
|
if(ncpp->slots == nullptr){
|
||||||
|
ncplane_destroy(n);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
memset(ncpp->slots, 0, slotsize);
|
memset(ncpp->slots, 0, slotsize);
|
||||||
ncpp->ncp = n;
|
ncpp->ncp = n;
|
||||||
ncpp->maxchannels = opts->maxchannels;
|
ncpp->maxchannels = opts->maxchannels;
|
||||||
@ -105,11 +114,10 @@ class ncppplot {
|
|||||||
ncpp->redraw_plot();
|
ncpp->redraw_plot();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroy(){
|
void destroy(){
|
||||||
free(slots);
|
free(slots);
|
||||||
|
ncplane_destroy(ncp);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto redraw_plot() -> int {
|
auto redraw_plot() -> int {
|
||||||
|
Loading…
Reference in New Issue
Block a user