non-Null handling for alloc.c
I wasn't very systematic but I think I eventually got everything. Most alloc.c declarations are in global.h rather than extern.h.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 extern.h $NHDT-Date: 1703070179 2023/12/20 11:02:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1344 $ */
|
||||
/* NetHack 3.7 extern.h $NHDT-Date: 1703716146 2023/12/27 22:29:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1356 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -70,14 +70,14 @@
|
||||
|
||||
#if 0
|
||||
/* routines in alloc.c depend on MONITOR_HEAP and are declared in global.h */
|
||||
extern long *alloc(unsigned int);
|
||||
extern long *alloc(unsigned int) NONNULL;
|
||||
#endif
|
||||
extern char *fmt_ptr(const void *) NONNULL;
|
||||
/* moved from hacklib.c to alloc.c so that utility programs have access */
|
||||
#define FITSint(x) FITSint_(x, __func__, __LINE__)
|
||||
extern int FITSint_(long long, const char *, int);
|
||||
extern int FITSint_(long long, const char *, int) NONNULLARG2;
|
||||
#define FITSuint(x) FITSuint_(x, __func__, __LINE__)
|
||||
extern unsigned FITSuint_(unsigned long long, const char *, int);
|
||||
extern unsigned FITSuint_(unsigned long long, const char *, int) NONNULLARG2;
|
||||
|
||||
/* This next pre-processor directive covers almost the entire file,
|
||||
* interrupted only occasionally to pick up specific functions as needed. */
|
||||
@@ -1404,7 +1404,7 @@ extern boolean is_home_elemental(struct permonst *) NONNULLARG1;
|
||||
extern struct monst *clone_mon(struct monst *, coordxy, coordxy) NONNULLARG1;
|
||||
extern int monhp_per_lvl(struct monst *) NONNULLARG1;
|
||||
extern void newmonhp(struct monst *, int) NONNULLARG1;
|
||||
extern struct mextra *newmextra(void);
|
||||
extern struct mextra *newmextra(void) NONNULL;
|
||||
extern struct monst *makemon(struct permonst *, coordxy, coordxy, mmflags_nht);
|
||||
extern struct monst *unmakemon(struct monst *, mmflags_nht) NONNULLARG1;
|
||||
extern boolean create_critters(int, struct permonst *, boolean);
|
||||
@@ -1561,7 +1561,7 @@ extern void restore_waterlevel(NHFILE *) NONNULLARG1;
|
||||
|
||||
/* ### mkobj.c ### */
|
||||
|
||||
extern struct oextra *newoextra(void);
|
||||
extern struct oextra *newoextra(void) NONNULL;
|
||||
extern void copy_oextra(struct obj *, struct obj *);
|
||||
extern void dealloc_oextra(struct obj *) NONNULLARG1;
|
||||
extern void newomonst(struct obj *) NONNULLARG1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 global.h $NHDT-Date: 1657918090 2022/07/15 20:48:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.144 $ */
|
||||
/* NetHack 3.7 global.h $NHDT-Date: 1703716158 2023/12/27 22:29:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.157 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -319,9 +319,10 @@ typedef uchar nhsym;
|
||||
if nethack is built with MONITOR_HEAP enabled and they aren't; this
|
||||
declaration has been moved out of the '#else' below to avoid getting
|
||||
a complaint from -Wmissing-prototypes when building with MONITOR_HEAP */
|
||||
extern char *dupstr(const char *) NONNULL;
|
||||
/* same, but return strlen(string) */
|
||||
extern char *dupstr_n(const char *string, unsigned int *lenout) NONNULL;
|
||||
extern char *dupstr(const char *) NONNULL NONNULLARG1;
|
||||
/* same, but return strlen(string) in extra argument */
|
||||
extern char *dupstr_n(const char *string,
|
||||
unsigned *lenout) NONNULL NONNULLPTRS;
|
||||
|
||||
/*
|
||||
* MONITOR_HEAP is conditionally used for primitive memory leak debugging.
|
||||
@@ -333,20 +334,15 @@ extern char *dupstr_n(const char *string, unsigned int *lenout) NONNULL;
|
||||
*/
|
||||
#ifdef MONITOR_HEAP
|
||||
/* plain alloc() is not declared except in alloc.c */
|
||||
extern long *nhalloc(unsigned int, const char *, int) NONNULL;
|
||||
extern long *nhrealloc(long *, unsigned int, const char *, int) NONNULL;
|
||||
extern void nhfree(genericptr_t, const char *, int);
|
||||
extern char *nhdupstr(const char *, const char *, int) NONNULL;
|
||||
extern long *nhalloc(unsigned int, const char *, int) NONNULL NONNULLARG2;
|
||||
extern long *nhrealloc(long *, unsigned int, const char *,
|
||||
int) NONNULL NONNULLARG3;
|
||||
extern void nhfree(genericptr_t, const char *, int) NONNULLARG2;
|
||||
extern char *nhdupstr(const char *, const char *, int) NONNULL NONNULLPTRS;
|
||||
/* this predates C99's __func__; that is trickier to use conditionally
|
||||
because it is not implemented as a preprocessor macro; MONITOR_HEAP
|
||||
wouldn't gain much benefit from it anyway so continue to live without it;
|
||||
if func's caller were accessible, that would be a very different issue */
|
||||
#ifndef __FILE__
|
||||
#define __FILE__ ""
|
||||
#endif
|
||||
#ifndef __LINE__
|
||||
#define __LINE__ 0
|
||||
#endif
|
||||
#define alloc(a) nhalloc(a, __FILE__, (int) __LINE__)
|
||||
#define re_alloc(a,n) nhrealloc(a, n, __FILE__, (int) __LINE__)
|
||||
#define free(a) nhfree(a, __FILE__, (int) __LINE__)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 alloc.c $NHDT-Date: 1687343500 2023/06/21 10:31:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.31 $ */
|
||||
/* NetHack 3.7 alloc.c $NHDT-Date: 1703716159 2023/12/27 22:29:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -15,9 +15,9 @@
|
||||
#endif
|
||||
|
||||
/*#define FITSint(x) FITSint_(x, __func__, (int) __LINE__)*/
|
||||
extern int FITSint_(LUA_INTEGER, const char *, int);
|
||||
extern int FITSint_(LUA_INTEGER, const char *, int) NONNULLARG2;
|
||||
/*#define FITSuint(x) FITSuint_(x, __func__, (int) __LINE__)*/
|
||||
extern unsigned FITSuint_(unsigned long long, const char *, int);
|
||||
extern unsigned FITSuint_(unsigned long long, const char *, int) NONNULLARG2;
|
||||
|
||||
char *fmt_ptr(const genericptr) NONNULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user