mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Keep track of dynamic buffer allocations.
This commit is contained in:
12
src/dynbuf.c
12
src/dynbuf.c
@@ -17,6 +17,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static size_t NumMallocs = 0;
|
||||||
|
static size_t BytesMalloced = 0;
|
||||||
|
|
||||||
|
void DBufGetMallocStats(size_t *num_mallocs, size_t *bytes_malloced)
|
||||||
|
{
|
||||||
|
*num_mallocs = NumMallocs;
|
||||||
|
*bytes_malloced = BytesMalloced;
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
%FUNCTION: DBufMakeRoom
|
%FUNCTION: DBufMakeRoom
|
||||||
%ARGUMENTS:
|
%ARGUMENTS:
|
||||||
@@ -45,6 +54,9 @@ static int DBufMakeRoom(DynamicBuffer *dbuf, size_t n)
|
|||||||
buf = malloc(size);
|
buf = malloc(size);
|
||||||
if (!buf) return E_NO_MEM;
|
if (!buf) return E_NO_MEM;
|
||||||
|
|
||||||
|
NumMallocs++;
|
||||||
|
BytesMalloced += size;
|
||||||
|
|
||||||
/* Copy contents */
|
/* Copy contents */
|
||||||
strcpy(buf, dbuf->buffer);
|
strcpy(buf, dbuf->buffer);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ int DBufPuts(DynamicBuffer *dbuf, char const *str);
|
|||||||
void DBufFree(DynamicBuffer *dbuf);
|
void DBufFree(DynamicBuffer *dbuf);
|
||||||
int DBufGets(DynamicBuffer *dbuf, FILE *fp);
|
int DBufGets(DynamicBuffer *dbuf, FILE *fp);
|
||||||
|
|
||||||
|
void DBufGetMallocStats(size_t *num_mallocs, size_t *bytes_malloced);
|
||||||
|
|
||||||
#define DBufValue(bufPtr) ((bufPtr)->buffer)
|
#define DBufValue(bufPtr) ((bufPtr)->buffer)
|
||||||
#define DBufLen(bufPtr) ((bufPtr)->len)
|
#define DBufLen(bufPtr) ((bufPtr)->len)
|
||||||
|
|
||||||
|
|||||||
@@ -62,12 +62,17 @@ exitfunc(void)
|
|||||||
/* Kill any execution-time-limiter process */
|
/* Kill any execution-time-limiter process */
|
||||||
unlimit_execution_time();
|
unlimit_execution_time();
|
||||||
|
|
||||||
|
size_t num_mallocs, bytes_malloced;
|
||||||
|
|
||||||
if (DebugFlag & DB_UNUSED_VARS) {
|
if (DebugFlag & DB_UNUSED_VARS) {
|
||||||
DumpUnusedVars();
|
DumpUnusedVars();
|
||||||
}
|
}
|
||||||
if (DebugFlag & DB_HASHSTATS) {
|
if (DebugFlag & DB_HASHSTATS) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(ErrFp);
|
fflush(ErrFp);
|
||||||
|
DBufGetMallocStats(&num_mallocs, &bytes_malloced);
|
||||||
|
fprintf(ErrFp, "DynBuf Mallocs: %lu mallocs; %lu bytes\n",
|
||||||
|
(unsigned long) num_mallocs, (unsigned long) bytes_malloced);
|
||||||
fprintf(ErrFp, "Variable hash table statistics:\n");
|
fprintf(ErrFp, "Variable hash table statistics:\n");
|
||||||
dump_var_hash_stats();
|
dump_var_hash_stats();
|
||||||
|
|
||||||
|
|||||||
@@ -16759,6 +16759,7 @@ mbpad("
|
|||||||
bad => "ÿ"
|
bad => "ÿ"
|
||||||
mbpad("ÿ", "bar", 8, 1) => Invalid multibyte sequence
|
mbpad("ÿ", "bar", 8, 1) => Invalid multibyte sequence
|
||||||
../tests/test.rem(1891): mbpad(): Invalid multibyte sequence
|
../tests/test.rem(1891): mbpad(): Invalid multibyte sequence
|
||||||
|
DynBuf Mallocs: 1114 mallocs; 31872128 bytes
|
||||||
Variable hash table statistics:
|
Variable hash table statistics:
|
||||||
Entries: 100146; Buckets: 87719; Non-empty Buckets: 66303
|
Entries: 100146; Buckets: 87719; Non-empty Buckets: 66303
|
||||||
Maxlen: 5; Minlen: 0; Avglen: 1.142; Stddev: 0.878; Avg nonempty len: 1.510
|
Maxlen: 5; Minlen: 0; Avglen: 1.142; Stddev: 0.878; Avg nonempty len: 1.510
|
||||||
@@ -24376,6 +24377,7 @@ Parsed expression: isany("foo", 1 + 1, 2:00 + 1, '2021-01-01' + 1, '2021-01-01@1
|
|||||||
"f" + "oo" => "foo"
|
"f" + "oo" => "foo"
|
||||||
isany("foo", 2, 02:01, 2021-01-02, 2021-01-01@14:01, "foo", ?) => 1
|
isany("foo", 2, 02:01, 2021-01-02, 2021-01-01@14:01, "foo", ?) => 1
|
||||||
No reminders.
|
No reminders.
|
||||||
|
DynBuf Mallocs: 21 mallocs; 6400 bytes
|
||||||
Variable hash table statistics:
|
Variable hash table statistics:
|
||||||
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
||||||
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
||||||
@@ -24974,6 +24976,7 @@ $WarningLevel
|
|||||||
$Was
|
$Was
|
||||||
$Wednesday
|
$Wednesday
|
||||||
No reminders.
|
No reminders.
|
||||||
|
DynBuf Mallocs: 180071 mallocs; 42974784 bytes
|
||||||
Variable hash table statistics:
|
Variable hash table statistics:
|
||||||
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
||||||
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
||||||
@@ -40003,6 +40006,7 @@ fib(24) = 46368
|
|||||||
-stdin-(13): `-': Maximum expression complexity exceeded
|
-stdin-(13): `-': Maximum expression complexity exceeded
|
||||||
-stdin-(3): [#0] In function `fib'
|
-stdin-(3): [#0] In function `fib'
|
||||||
[remaining call frames omitted]
|
[remaining call frames omitted]
|
||||||
|
DynBuf Mallocs: 3 mallocs; 192 bytes
|
||||||
Variable hash table statistics:
|
Variable hash table statistics:
|
||||||
Entries: 0; Buckets: 7; Non-empty Buckets: 0
|
Entries: 0; Buckets: 7; Non-empty Buckets: 0
|
||||||
Maxlen: 0; Minlen: 0; Avglen: 0.000; Stddev: 0.000; Avg nonempty len: 0.000
|
Maxlen: 0; Minlen: 0; Avglen: 0.000; Stddev: 0.000; Avg nonempty len: 0.000
|
||||||
@@ -40028,6 +40032,7 @@ Total expression node evaluations: 3999940
|
|||||||
a = 493; hex(a) = 1ED
|
a = 493; hex(a) = 1ED
|
||||||
hex(-1) = FFFFFFFF
|
hex(-1) = FFFFFFFF
|
||||||
a = 32767; hex(a) = 7FFF
|
a = 32767; hex(a) = 7FFF
|
||||||
|
DynBuf Mallocs: 5 mallocs; 320 bytes
|
||||||
Variable hash table statistics:
|
Variable hash table statistics:
|
||||||
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
Entries: 1; Buckets: 7; Non-empty Buckets: 1
|
||||||
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
Maxlen: 1; Minlen: 0; Avglen: 0.143; Stddev: 0.350; Avg nonempty len: 1.000
|
||||||
|
|||||||
Reference in New Issue
Block a user