strdup/dupstr (trunk only)
Add dupstr() as a substitute for strdup() so that out-of-memory
handling will be consistent with the rest of nethack, and make it aware
of nethack's heap logging. It's treated like alloc() so that its caller
can be logged for NH_HEAPLOG.
I put it into use in a few places, but there are lots more candidates
besides the existing calls to strdup() that should be replaced.
This commit is contained in:
@@ -297,6 +297,7 @@ typedef char nhptext;
|
||||
#ifdef MONITOR_HEAP
|
||||
extern long *FDECL(nhalloc, (unsigned int,const char *,int));
|
||||
extern void FDECL(nhfree, (genericptr_t,const char *,int));
|
||||
extern char *FDECL(nhdupstr, (const char *,const char *,int));
|
||||
# ifndef __FILE__
|
||||
# define __FILE__ ""
|
||||
# endif
|
||||
@@ -305,8 +306,10 @@ extern void FDECL(nhfree, (genericptr_t,const char *,int));
|
||||
# endif
|
||||
# define alloc(a) nhalloc(a,__FILE__,(int)__LINE__)
|
||||
# define free(a) nhfree(a,__FILE__,(int)__LINE__)
|
||||
# define dupstr(s) nhdupstr(s,__FILE__,(int)__LINE__)
|
||||
#else /* !MONITOR_HEAP */
|
||||
extern long *FDECL(alloc, (unsigned int)); /* alloc.c */
|
||||
extern char *FDECL(dupstr, (const char *)); /* ditto */
|
||||
#endif
|
||||
|
||||
/* Used for consistency checks of various data files; declare it here so
|
||||
|
||||
Reference in New Issue
Block a user