diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index e91d6bc72..8f0937b9c 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -554,6 +554,7 @@ cell_init(cell* c){ // Breaks the UTF-8 string in 'gcluster' down, setting up the cell 'c'. Returns // the number of bytes copied out of 'gcluster', or -1 on failure. The styling // of the cell is left untouched, but any resources are released. +__attribute__ ((nonnull (1, 2, 3))) API int cell_load(struct ncplane* n, cell* c, const char* gcluster); // cell_load(), plus blast the styling with 'attr' and 'channels'. diff --git a/src/lib/egcpool.h b/src/lib/egcpool.h index f4fb716b5..df836aa7e 100644 --- a/src/lib/egcpool.h +++ b/src/lib/egcpool.h @@ -110,7 +110,7 @@ egcpool_alloc_justified(const egcpool* pool, int len){ // should not be less than 2 bytes (such a cluster should be directly stored in // the cell). returns -1 on error, and otherwise a non-negative offset. 'ulen' // must be the number of bytes to lift from egc (utf8_egc_len()). -static inline int +__attribute__ ((nonnull (1, 2))) static inline int egcpool_stash(egcpool* pool, const char* egc, size_t ulen){ int len = ulen + 1; // count the NUL terminator if(len <= 2){ // should never be empty, nor a single byte + NUL @@ -236,8 +236,8 @@ egcpool_dump(egcpool* pool){ pool->poolused = 0; } -static inline const char* -egcpool_extended_gcluster(const egcpool* pool, const cell* c){ +__attribute__ ((__returns_nonnull__)) static inline const char* +egcpool_extended_gcluster(const egcpool* pool, const cell* c) { uint32_t idx = cell_egc_idx(c); return pool->pool + idx; } diff --git a/src/lib/internal.h b/src/lib/internal.h index cf287c152..d5a4950ec 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -599,8 +599,9 @@ cell_duplicate_far(egcpool* tpool, cell* targ, const ncplane* splane, const cell targ->gcluster = c->gcluster; return !!c->gcluster; } - size_t ulen = strlen(extended_gcluster(splane, c)); - int eoffset = egcpool_stash(tpool, extended_gcluster(splane, c), ulen); + const char* egc = extended_gcluster(splane, c); + size_t ulen = strlen(egc); + int eoffset = egcpool_stash(tpool, egc, ulen); if(eoffset < 0){ return -1; } diff --git a/src/lib/render.c b/src/lib/render.c index 4c2dc61c7..6cf3ba5bd 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -374,6 +374,7 @@ fprintf(stderr, "WROTE %u [%s] to %d/%d (%d/%d)\n", targc->gcluster, extended_gc return 0; } +// it's not a pure memset(), because CELL_ALPHA_OPAQUE is the zero value static void init_fb(cell* fb, int dimy, int dimx){ for(int y = 0 ; y < dimy ; ++y){