Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dankamongmen/ncplan…
Browse files Browse the repository at this point in the history
…e-as-rgba
  • Loading branch information
dankamongmen committed May 31, 2021
2 parents a8e07fa + 1f1bbad commit 3d95fe7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/demo/hud.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ int fpsgraph_init(struct notcurses* nc){
ncchannels_set_fg_rgb8(&opts.maxchannels, 0x80, 0xff, 0x80);
ncchannels_set_bg_rgb(&opts.maxchannels, 0x201020);
ncchannels_set_bg_alpha(&opts.maxchannels, CELL_ALPHA_BLEND);
// takes ownership of newp on all paths
struct ncuplot* fpsplot = ncuplot_create(newp, &opts, 0, 0);
if(!fpsplot){
ncplane_destroy(newp);
return EXIT_FAILURE;
}
plot = fpsplot;
Expand Down
28 changes: 16 additions & 12 deletions src/lib/plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,17 @@ void destroy_##T(nc##X##plot* ncpp){ \
CREATE(uint64_t, u)
CREATE(double, d)

// takes ownership of n on all paths
ncuplot* ncuplot_create(ncplane* n, const ncplot_options* opts, uint64_t miny, uint64_t maxy){
ncuplot* ret = malloc(sizeof(*ret));
if(ret){
memset(ret, 0, sizeof(*ret));
if(create_uint64_t(ret, n, opts, miny, maxy, 0, UINT64_MAX)){
return ret;
}
if(ret == NULL){
ncplane_destroy(n);
return NULL;
}
memset(ret, 0, sizeof(*ret));
if(!create_uint64_t(ret, n, opts, miny, maxy, 0, UINT64_MAX)){
free(ret);
ret = NULL;
return NULL;
}
return ret;
}
Expand All @@ -447,15 +449,17 @@ void ncuplot_destroy(ncuplot* n){
}
}

// takes ownership of n on all paths
ncdplot* ncdplot_create(ncplane* n, const ncplot_options* opts, double miny, double maxy){
ncdplot* ret = malloc(sizeof(*ret));
if(ret){
memset(ret, 0, sizeof(*ret));
if(create_double(ret, n, opts, miny, maxy, -DBL_MAX, DBL_MAX)){
return ret;
}
if(ret == NULL){
ncplane_destroy(n);
return NULL;
}
memset(ret, 0, sizeof(*ret));
if(!create_double(ret, n, opts, miny, maxy, -DBL_MAX, DBL_MAX)){
free(ret);
ret = NULL;
return NULL;
}
return ret;
}
Expand Down

0 comments on commit 3d95fe7

Please sign in to comment.