Added some TODO notes about handling realloc() failures
This commit is contained in:
		@@ -412,6 +412,7 @@ static termkey_keysym register_csifunc_full(termkey_csi *csi, termkey_type type,
 | 
			
		||||
 | 
			
		||||
  if(number >= csi->ncsifuncs) {
 | 
			
		||||
    struct keyinfo *new_csifuncs = realloc(csi->csifuncs, sizeof(new_csifuncs[0]) * (number + 1));
 | 
			
		||||
    // TODO: Handle realloc() failure
 | 
			
		||||
    csi->csifuncs = new_csifuncs;
 | 
			
		||||
 | 
			
		||||
    // Fill in the hole
 | 
			
		||||
 
 | 
			
		||||
@@ -180,7 +180,7 @@ static void register_seq(termkey_ti *ti, const char *seq, termkey_type type, ter
 | 
			
		||||
  if(ti->nseqs == ti->alloced_seqs) {
 | 
			
		||||
    ti->alloced_seqs *= 2;
 | 
			
		||||
    void *newseqs = realloc(ti->seqs, ti->alloced_seqs * sizeof(ti->seqs[9]));
 | 
			
		||||
    // TODO: Error handle
 | 
			
		||||
    // TODO: Handle realloc() failure
 | 
			
		||||
    ti->seqs = newseqs;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -471,6 +471,7 @@ void termkey_pushinput(termkey_t *tk, unsigned char *input, size_t inputlen)
 | 
			
		||||
      tk->buffsize *= 2;
 | 
			
		||||
 | 
			
		||||
    unsigned char *newbuffer = realloc(tk->buffer, tk->buffsize);
 | 
			
		||||
    // TODO: Handle realloc() failure
 | 
			
		||||
    tk->buffer = newbuffer;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -503,6 +504,7 @@ termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym sym, const
 | 
			
		||||
 | 
			
		||||
  if(sym >= tk->nkeynames) {
 | 
			
		||||
    const char **new_keynames = realloc(tk->keynames, sizeof(new_keynames[0]) * (sym + 1));
 | 
			
		||||
    // TODO: Handle realloc() failure
 | 
			
		||||
    tk->keynames = new_keynames;
 | 
			
		||||
 | 
			
		||||
    // Fill in the hole
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user