Bläddra i källkod

realloc() behaves like free() if size is 0

master
sin 10 år sedan
förälder
incheckning
8d018e620f
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. +2
    -2
      noice.c

+ 2
- 2
noice.c Visa fil

@@ -366,9 +366,9 @@ readln(void)
if (c == KEY_BACKSPACE) { if (c == KEY_BACKSPACE) {
getyx(stdscr, y, x); getyx(stdscr, y, x);
if (x >= x0) { if (x >= x0) {
i--;
if (i > 0) { if (i > 0) {
ln = xrealloc(ln, (i - 1) * sizeof(*ln)); ln = xrealloc(ln, i * sizeof(*ln));
i--;
} else { } else {
free(ln); free(ln);
ln = NULL; ln = NULL;


||||||
x
 
000:0
Laddar…
Avbryt
Spara