mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Make emacs not croak when editing dlmalloc
This commit is contained in:
parent
3c7ae0fc72
commit
fa1e8a3e65
21 changed files with 3019 additions and 2985 deletions
56
third_party/dlmalloc/hooks.inc
vendored
Normal file
56
third_party/dlmalloc/hooks.inc
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
// clang-format off
|
||||
|
||||
/* ------------------------------- Hooks -------------------------------- */
|
||||
|
||||
/*
|
||||
PREACTION should be defined to return 0 on success, and nonzero on
|
||||
failure. If you are not using locking, you can redefine these to do
|
||||
anything you like.
|
||||
*/
|
||||
|
||||
#if USE_LOCKS
|
||||
#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
|
||||
#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
|
||||
#else /* USE_LOCKS */
|
||||
|
||||
#ifndef PREACTION
|
||||
#define PREACTION(M) (0)
|
||||
#endif /* PREACTION */
|
||||
|
||||
#ifndef POSTACTION
|
||||
#define POSTACTION(M)
|
||||
#endif /* POSTACTION */
|
||||
|
||||
#endif /* USE_LOCKS */
|
||||
|
||||
/*
|
||||
CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
|
||||
USAGE_ERROR_ACTION is triggered on detected bad frees and
|
||||
reallocs. The argument p is an address that might have triggered the
|
||||
fault. It is ignored by the two predefined actions, but might be
|
||||
useful in custom actions that try to help diagnose errors.
|
||||
*/
|
||||
|
||||
#if PROCEED_ON_ERROR
|
||||
|
||||
/* A count of the number of corruption errors causing resets */
|
||||
int malloc_corruption_error_count;
|
||||
|
||||
/* default corruption action */
|
||||
static void reset_on_error(mstate m);
|
||||
|
||||
#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m)
|
||||
#define USAGE_ERROR_ACTION(m, p)
|
||||
|
||||
#else /* PROCEED_ON_ERROR */
|
||||
|
||||
#ifndef CORRUPTION_ERROR_ACTION
|
||||
#define CORRUPTION_ERROR_ACTION(m) ABORT
|
||||
#endif /* CORRUPTION_ERROR_ACTION */
|
||||
|
||||
#ifndef USAGE_ERROR_ACTION
|
||||
#define USAGE_ERROR_ACTION(m,p) ABORT
|
||||
#endif /* USAGE_ERROR_ACTION */
|
||||
|
||||
#endif /* PROCEED_ON_ERROR */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue