]> granicus.if.org Git - nethack/commitdiff
fix up a couple of realloc comments
authorPatR <rankin@nethack.org>
Tue, 31 May 2022 13:10:22 +0000 (06:10 -0700)
committerPatR <rankin@nethack.org>
Tue, 31 May 2022 13:10:22 +0000 (06:10 -0700)
src/alloc.c

index f0fb41a71a1c3838d51a93b9bce320d9268749af..244dc2cb8be097f15e11c158a09b631da61b8d48 100644 (file)
@@ -62,18 +62,18 @@ alloc(unsigned int lth)
 #endif
 }
 
-/* realloc() call that might get substituted by nhrealloc(p,l,file,line) */
+/* realloc() call that might get substituted by nhrealloc(p,n,file,line) */
 long *
 re_alloc(long *oldptr, unsigned int newlth)
 {
     /*
-     * if LINT support ever gets resurrected,
-     * we probably need some hackery here
+     * If LINT support ever gets resurrected,
+     * we'll probably need some hackery here.
      */
 
     long *newptr = (long *) realloc((genericptr_t) oldptr, (size_t) newlth);
 #ifndef MONITOR_HEAP
-    /* "extend":  assume if won't ever fail if asked to shrink */
+    /* "extend to":  assume it won't ever fail if asked to shrink */
     if (newlth && !newptr)
         panic("Memory allocation failure; cannot extend to %u bytes", newlth);
 #endif
@@ -172,8 +172,10 @@ nhrealloc(
         (void) fprintf(heaplog, "%c%5u %s %4d %s\n", op, newlth,
                            fmt_ptr((genericptr_t) newptr), line, file);
     }
-    /* potential panic in re_alloc() was deferred til here */
-    /* "extend to":  assume if won't ever fail if asked to shrink */
+    /* potential panic in re_alloc() was deferred til here;
+       "extend to":  assume it won't ever fail if asked to shrink;
+       even if that assumption happens to be wrong, we lack access to
+       the old size so can't use alternate phrasing for that case */
     if (newlth && !newptr)
         panic("Cannot extend to %u bytes, line %d of %s", newlth, line, file);