a4_0016
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* acl4のページ0016
-(by [[K]], 2026.04.23)
** (1) 概要
-a4_0016 は、 acl4v1 にとっての一番最初のライブラリプログ...
-提供される主な機能は、以下の通りです。
--(1-1)主要な標準関数をすべてインクルード
--(1-2)便利関数・便利マクロ(static_, class_, errExit, Li...
--(1-3)デバッグ支援関数(malloc_, free_, realloc_, DbgObj...
-以下、それぞれについてもう少し詳しく説明します。
~
-(1-1)主要な標準関数をすべてインクルード
--標準関数を使う際にわざわざ毎回 include を書くのは面倒な...
--このためだけに acl4 を使うこともあるくらいです(笑)。
-(1-2)便利関数・便利マクロ(static_, class_, errExit, Lis...
--[static_] acl4 ではすべての関数に static 属性がデフォル...
--かつては私も分割コンパイル推進派でしたが、CPUの性能が上...
--しかしもしかしたら分割コンパイルをやりたいと思うことが...
--[class_] C言語には struct で構造体を宣言する機能があり...
--Cでも typedef で宣言しておけば「使うときの struct 」を...
--[errExit] 「エラーメッセージを stderr に出力して終了」...
--[List] 私は双方向リストが好きなのですが、たまにつなぎ間...
-(1-3)デバッグ支援関数(malloc_, free_, realloc_, DbgObjI...
--[malloc_] malloc_ や realloc_ は、NULLを返しません。メ...
--こういう仕様なのは、もはやメモリ不足を起こしてしまうの...
--malloc_ で得られたメモリ領域は、(デバッグモードであれ...
--[free_ ] 当たり前ですが、 malloc_ や realloc_ で得たポ...
--free_ の際には中身を全部 0x87 で塗りつぶしてから free ...
--[DbgObjInf] オブジェクトの init/deinit の対応状態を管理...
--malloc_ や DbgObjInf は、現在有効になっているもののリス...
** (2) デモ
-わざとfreeをやり忘れたり、deinitをやり忘れたりして、どの...
-手ごろなクラスがなかったので a4_0017 の内容を先取りして...
-''[t0016a.c]:''
#define a_Version 1
#include <acl4v1.c>
int main(void)
{
char *a[5];
a[0] = malloc_(_a_ 1); // このように malloc/free/ini...
a[1] = malloc_(_a_ 3);
a[2] = malloc_(_a_ 5);
a[3] = malloc_(_a_ 7);
a[4] = malloc_(_a_ 9);
free_(_a_ a[1], 3);
free_(_a_ a[3], 7);
VecChr vc[1]; VecChr_ini(_a_ vc);
a_malloc_debugList(_a); // a[0], a[2], a[4]は未開放...
a_DbgObjInfTbl_debugList(_a); // vcは未開放なので、...
return 0;
}
-実行結果:
>t0016a
t0016a.c(15): malloc_debugList()
[p:012dccb0 sz:1 / t0016a.c(7)]
[p:012dc868 sz:5 / t0016a.c(9)]
[p:012dc8c8 sz:9 / t0016a.c(11)]
t0016a.c(16): DbgObjInfTbl_debugList()
[VecChr / t0016a.c(14)]
-注意点として、a_malloc_debugList()で表示されるpの値は、...
-しかしデバッグにおいては、64bitすべてが表示されていなく...
** (3) ライブラリプログラム
#if (!defined(a_DbgLv))
#define a_DbgLv 2
#endif
#if (!defined(a_Version))
#define a_Version 9999
#endif
#if (a_DbgLv < 1)
#define a_DbgLv1(x)
#else
#define a_DbgLv1(x) x
#endif
#if (a_DbgLv < 2)
#define _aDef_
#define _aDef
#define _a_
#define _a
#define _aThr_
#define _aThr
#define a_DbgLv2(x)
#else
#define _aDef_ const char *a_fil, int a_lin,
#define _aDef const char *a_fil, int a_lin
#define _a_ __FILE__, __LINE__,
#define _a __FILE__, __LINE__
#define _aThr_ a_fil, a_lin,
#define _aThr a_fil, a_lin
#define a_DbgLv2(x) x
#endif
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if (a_Version >= 1)
#define static_ a_static
#define class_ a_class
#define DbgLv a_DbgLv
#define DM a_DM
#define DbgLv1 a_DbgLv1
#define DbgLv2 a_DbgLv2
#define errExit a_errExit
#define List a_List
#define List_ini a_List_ini
#define List_addTl a_List_addTl
#define List_addHd a_List_addHd
#define List_rmv a_List_rmv
#define malloc_ a_malloc
#define free_ a_free
#define realloc_ a_realloc
#define DbgObjInf a_DbgObjInf
#define DbgObjInf_ini a_DbgObjInf_ini
#define DbgObjInf_din a_DbgObjInf_din
#endif
#if (!defined(a_static))
#define a_static static
#endif
#define a_class(nam) typedef struct nam ## _ nam; str...
a_static void a_errExit(const char *f, ...)
{
va_list ap;
va_start(ap, f);
vfprintf(stderr, f, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}
#define a_DM a_DbgLv2( fprintf(stderr, "%s(%d): DebugMes...
a_class(a_List) { a_List *prv, *nxt; };
a_static void a_List_ini(a_List *w) { w->prv = w->nxt = ...
a_static void a_List_add(a_List *prv, a_List *tgt, a_Lis...
{
prv->nxt = tgt;
tgt->prv = prv;
tgt->nxt = nxt;
nxt->prv = tgt;
}
a_static void a_List_rmv(a_List *prv, a_List *nxt) { prv...
a_static void a_List_addTl(a_List *w, a_List *tgt) { a_L...
a_static void a_List_addHd(a_List *w, a_List *tgt) { a_L...
a_class(a_malloc_Header) {
a_List lst[1];
intptr_t dmy[1], sz, lin;
const char *fil;
intptr_t serialNum, sig;
};
a_static a_malloc_Header a_malloc_hed0[1];
#define a_malloc_Sig 0xff0055aa
a_static void *a_malloc(_aDef_ intptr_t sz)
{
#if (a_DbgLv < 2)
void *p = malloc(sz);
if (p == NULL)
a_errExit("malloc_: out of memory: sz=%d");
return p;
#else
if (sz < 0)
a_errExit("%s(%d): malloc_ size error: sz=%d...
a_malloc_Header *h = (a_malloc_Header *) malloc(...
if (h == NULL)
a_errExit("%s(%d): malloc_: out of memory: s...
memset(h, 0x87, sz + sizeof (a_malloc_Header));
if (a_malloc_hed0->lst->prv == NULL) {
a_List_ini(a_malloc_hed0->lst);
a_malloc_hed0->sz = -1;
a_malloc_hed0->sig = a_malloc_Sig;
a_malloc_hed0->lin = 0;
}
a_List_addTl(a_malloc_hed0->lst, h->lst);
h->sz = sz;
h->sig = a_malloc_Sig;
h->lin = a_lin;
h->fil = a_fil;
h->serialNum = ++(a_malloc_hed0->serialNum);
a_malloc_hed0->lin++;
return h + 1;
#endif
}
a_static void a_free(_aDef_ void *p, intptr_t sz)
{
#if (a_DbgLv < 2)
(void) sz;
free(p);
#else
if (p == NULL) return;
a_malloc_Header *h = (a_malloc_Header *) p - 1;
if (h->sig != a_malloc_Sig)
a_errExit("%s(%d): free_: bad signature", a_...
if (h->sz != sz)
a_errExit("%s(%d): free_: bad size: sz=%d, a...
// h->sig = 0; h->serialNum = 0; // memsetがあるか...
a_List_rmv(h->lst->prv, h->lst->nxt);
a_malloc_hed0->lin--;
memset(h, 0x87, sz + sizeof (a_malloc_Header));
free(h);
#endif
}
a_static void *a_realloc(_aDef_ void *p, intptr_t sz0, ...
{
#if (a_DbgLv < 2)
(void) sz0;
p = realloc(p, sz1);
if (p == NULL)
a_errExit("realloc_: out of memory: sz1=%d");
return p;
#else
if (sz1 < 0)
a_errExit("%s(%d): realloc_ size error: sz1=...
if (p == NULL)
return a_malloc(_aThr, sz1);
a_malloc_Header *h = (a_malloc_Header *) p - 1;
if (h->sig != a_malloc_Sig)
a_errExit("%s(%d): realloc_: bad signature",...
if (h->sz != sz0)
a_errExit("%s(%d): realloc_: bad size: sz=%d...
h->sig = 0;
intptr_t sn = h->serialNum;
h->serialNum = 0;
a_List *prv = h->lst->prv;
a_List *nxt = h->lst->nxt;
a_List_rmv(prv, nxt);
#if 0
a_malloc_Header *h1 = (a_malloc_Header *) reallo...
// これだと古い領域を利用させないためのmemse...
if (h1 == NULL)
a_errExit("%s(%d): realloc_: out of memory: ...
#elif 1
a_malloc_Header *h1 = h;
if (sz0 > sz1)
memset(((char *) h) + sz1 + sizeof (a_malloc...
if (sz0 < sz1) {
h1 = malloc(sz1 + sizeof (a_malloc_Header));
if (h1 == NULL)
a_errExit("%s(%d): realloc_: out of memo...
memcpy(h1, h, sz0 + sizeof (a_malloc_Header));
memset(h, 0x87, sz0 + sizeof (a_malloc_Heade...
free(h);
memset(((char *) h1) + sz0 + sizeof (a_mallo...
}
#endif
a_List_add(prv, h1->lst, nxt);
h1->sig = a_malloc_Sig;
h1->serialNum = sn;
h1->sz = sz1;
// h1->lin = a_lin; h1->fil = a_fil; // reallocした...
return h1 + 1;
#endif
}
a_static void a_malloc_debugList(_aDef)
{
#if (a_DbgLv >= 2)
fprintf(stderr, "%s(%d): malloc_debugList()\n", ...
if (a_malloc_hed0->lst->prv != NULL) {
a_List *t = a_malloc_hed0->lst->nxt;
for (;;) {
a_malloc_Header *h = (a_malloc_Header *)...
if (h->sz < 0) break;
fprintf(stderr, " [p:%08x sz:%d / %s(%d...
t = t->nxt;
}
}
#endif
}
a_class(a_DbgObjInf) { intptr_t tblIdx, sig; };
a_class(a_DbgObjInfTbl) { intptr_t prv, nxt, lin; const ...
a_static a_DbgObjInfTbl *a_DbgObjInfTbl_p;
a_static intptr_t a_DbgObjInfTbl_nxt = -1, a_DbgObjInfTb...
a_static int64_t a_DbgObjInfTbl_sn = 0;
a_static void a_DbgObjInfTbl_extSiz()
{
intptr_t i0 = a_DbgObjInfTbl_n1, i1, i;
if (a_DbgObjInfTbl_n1 == 0) {
a_DbgObjInfTbl_n1 = 256;
a_DbgObjInfTbl_p = malloc(a_DbgObjInfTbl_n1 * si...
} else {
a_DbgObjInfTbl_n1 <<= 1;
a_DbgObjInfTbl_p = realloc(a_DbgObjInfTbl_p, a_D...
}
i1 = a_DbgObjInfTbl_n1;
if (a_DbgObjInfTbl_p == NULL)
a_errExit("a_DbgObjInfTbl_extSiz: out of memory:...
for (i = i0; i < i1; i++) {
a_DbgObjInfTbl_p[i].nxt = i + 1;
a_DbgObjInfTbl_p[i].lin = -1;
}
a_DbgObjInfTbl_p[i1 - 1].nxt = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = i0;
if (a_DbgObjInfTbl_nxt == 0) {
a_DbgObjInfTbl_nxt = 1;
a_DbgObjInfTbl_p[0].prv = 0;
a_DbgObjInfTbl_p[0].nxt = 0;
}
}
a_static void a_DbgObjInf_ini(const char *a_fil, int a_l...
{
if (a_DbgObjInfTbl_nxt < 0) a_DbgObjInfTbl_extSiz();
intptr_t i = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = a_DbgObjInfTbl_p[i].nxt;
a_DbgObjInfTbl_p[i].lin = a_lin;
a_DbgObjInfTbl_p[i].nam = nam;
a_DbgObjInfTbl_p[i].fil = a_fil;
a_DbgObjInfTbl_p[i].sn = a_DbgObjInfTbl_sn++;
a_DbgObjInfTbl_n++;
if (w->sig == a_malloc_Sig && 0 < w->tblIdx && w->tb...
a_errExit("%s(%d): a_DbgObjInf_ini: bad signatur...
w->tblIdx = i;
w->sig = a_malloc_Sig;
intptr_t p = a_DbgObjInfTbl_p[0].prv;
a_DbgObjInfTbl_p[p].nxt = i;
a_DbgObjInfTbl_p[i].prv = p;
a_DbgObjInfTbl_p[i].nxt = 0;
a_DbgObjInfTbl_p[0].prv = i;
}
a_static void a_DbgObjInf_din(const char *a_fil, int a_l...
{
if (w->sig != a_malloc_Sig)
a_errExit("%s(%d): a_DbgObjInf_din: bad signatur...
w->sig = 0;
intptr_t i = w->tblIdx;
a_DbgObjInfTbl_p[i].lin = -1;
a_DbgObjInfTbl_n--;
intptr_t p = a_DbgObjInfTbl_p[i].prv, n = a_DbgObjIn...
a_DbgObjInfTbl_p[p].nxt = n;
a_DbgObjInfTbl_p[n].prv = p;
a_DbgObjInfTbl_p[i].nxt = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = i;
}
a_static void a_DbgObjInfTbl_debugList(_aDef)
{
#if (a_DbgLv >= 2)
fprintf(stderr, "%s(%d): DbgObjInfTbl_debugList(...
intptr_t i = a_DbgObjInfTbl_p[0].nxt;
while (i > 0) {
fprintf(stderr, " [%s / %s(%d)]\n", a_DbgOb...
i = a_DbgObjInfTbl_p[i].nxt;
}
#endif
}
** (99) 更新履歴
-2026.04.23(木) 初版
終了行:
* acl4のページ0016
-(by [[K]], 2026.04.23)
** (1) 概要
-a4_0016 は、 acl4v1 にとっての一番最初のライブラリプログ...
-提供される主な機能は、以下の通りです。
--(1-1)主要な標準関数をすべてインクルード
--(1-2)便利関数・便利マクロ(static_, class_, errExit, Li...
--(1-3)デバッグ支援関数(malloc_, free_, realloc_, DbgObj...
-以下、それぞれについてもう少し詳しく説明します。
~
-(1-1)主要な標準関数をすべてインクルード
--標準関数を使う際にわざわざ毎回 include を書くのは面倒な...
--このためだけに acl4 を使うこともあるくらいです(笑)。
-(1-2)便利関数・便利マクロ(static_, class_, errExit, Lis...
--[static_] acl4 ではすべての関数に static 属性がデフォル...
--かつては私も分割コンパイル推進派でしたが、CPUの性能が上...
--しかしもしかしたら分割コンパイルをやりたいと思うことが...
--[class_] C言語には struct で構造体を宣言する機能があり...
--Cでも typedef で宣言しておけば「使うときの struct 」を...
--[errExit] 「エラーメッセージを stderr に出力して終了」...
--[List] 私は双方向リストが好きなのですが、たまにつなぎ間...
-(1-3)デバッグ支援関数(malloc_, free_, realloc_, DbgObjI...
--[malloc_] malloc_ や realloc_ は、NULLを返しません。メ...
--こういう仕様なのは、もはやメモリ不足を起こしてしまうの...
--malloc_ で得られたメモリ領域は、(デバッグモードであれ...
--[free_ ] 当たり前ですが、 malloc_ や realloc_ で得たポ...
--free_ の際には中身を全部 0x87 で塗りつぶしてから free ...
--[DbgObjInf] オブジェクトの init/deinit の対応状態を管理...
--malloc_ や DbgObjInf は、現在有効になっているもののリス...
** (2) デモ
-わざとfreeをやり忘れたり、deinitをやり忘れたりして、どの...
-手ごろなクラスがなかったので a4_0017 の内容を先取りして...
-''[t0016a.c]:''
#define a_Version 1
#include <acl4v1.c>
int main(void)
{
char *a[5];
a[0] = malloc_(_a_ 1); // このように malloc/free/ini...
a[1] = malloc_(_a_ 3);
a[2] = malloc_(_a_ 5);
a[3] = malloc_(_a_ 7);
a[4] = malloc_(_a_ 9);
free_(_a_ a[1], 3);
free_(_a_ a[3], 7);
VecChr vc[1]; VecChr_ini(_a_ vc);
a_malloc_debugList(_a); // a[0], a[2], a[4]は未開放...
a_DbgObjInfTbl_debugList(_a); // vcは未開放なので、...
return 0;
}
-実行結果:
>t0016a
t0016a.c(15): malloc_debugList()
[p:012dccb0 sz:1 / t0016a.c(7)]
[p:012dc868 sz:5 / t0016a.c(9)]
[p:012dc8c8 sz:9 / t0016a.c(11)]
t0016a.c(16): DbgObjInfTbl_debugList()
[VecChr / t0016a.c(14)]
-注意点として、a_malloc_debugList()で表示されるpの値は、...
-しかしデバッグにおいては、64bitすべてが表示されていなく...
** (3) ライブラリプログラム
#if (!defined(a_DbgLv))
#define a_DbgLv 2
#endif
#if (!defined(a_Version))
#define a_Version 9999
#endif
#if (a_DbgLv < 1)
#define a_DbgLv1(x)
#else
#define a_DbgLv1(x) x
#endif
#if (a_DbgLv < 2)
#define _aDef_
#define _aDef
#define _a_
#define _a
#define _aThr_
#define _aThr
#define a_DbgLv2(x)
#else
#define _aDef_ const char *a_fil, int a_lin,
#define _aDef const char *a_fil, int a_lin
#define _a_ __FILE__, __LINE__,
#define _a __FILE__, __LINE__
#define _aThr_ a_fil, a_lin,
#define _aThr a_fil, a_lin
#define a_DbgLv2(x) x
#endif
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if (a_Version >= 1)
#define static_ a_static
#define class_ a_class
#define DbgLv a_DbgLv
#define DM a_DM
#define DbgLv1 a_DbgLv1
#define DbgLv2 a_DbgLv2
#define errExit a_errExit
#define List a_List
#define List_ini a_List_ini
#define List_addTl a_List_addTl
#define List_addHd a_List_addHd
#define List_rmv a_List_rmv
#define malloc_ a_malloc
#define free_ a_free
#define realloc_ a_realloc
#define DbgObjInf a_DbgObjInf
#define DbgObjInf_ini a_DbgObjInf_ini
#define DbgObjInf_din a_DbgObjInf_din
#endif
#if (!defined(a_static))
#define a_static static
#endif
#define a_class(nam) typedef struct nam ## _ nam; str...
a_static void a_errExit(const char *f, ...)
{
va_list ap;
va_start(ap, f);
vfprintf(stderr, f, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}
#define a_DM a_DbgLv2( fprintf(stderr, "%s(%d): DebugMes...
a_class(a_List) { a_List *prv, *nxt; };
a_static void a_List_ini(a_List *w) { w->prv = w->nxt = ...
a_static void a_List_add(a_List *prv, a_List *tgt, a_Lis...
{
prv->nxt = tgt;
tgt->prv = prv;
tgt->nxt = nxt;
nxt->prv = tgt;
}
a_static void a_List_rmv(a_List *prv, a_List *nxt) { prv...
a_static void a_List_addTl(a_List *w, a_List *tgt) { a_L...
a_static void a_List_addHd(a_List *w, a_List *tgt) { a_L...
a_class(a_malloc_Header) {
a_List lst[1];
intptr_t dmy[1], sz, lin;
const char *fil;
intptr_t serialNum, sig;
};
a_static a_malloc_Header a_malloc_hed0[1];
#define a_malloc_Sig 0xff0055aa
a_static void *a_malloc(_aDef_ intptr_t sz)
{
#if (a_DbgLv < 2)
void *p = malloc(sz);
if (p == NULL)
a_errExit("malloc_: out of memory: sz=%d");
return p;
#else
if (sz < 0)
a_errExit("%s(%d): malloc_ size error: sz=%d...
a_malloc_Header *h = (a_malloc_Header *) malloc(...
if (h == NULL)
a_errExit("%s(%d): malloc_: out of memory: s...
memset(h, 0x87, sz + sizeof (a_malloc_Header));
if (a_malloc_hed0->lst->prv == NULL) {
a_List_ini(a_malloc_hed0->lst);
a_malloc_hed0->sz = -1;
a_malloc_hed0->sig = a_malloc_Sig;
a_malloc_hed0->lin = 0;
}
a_List_addTl(a_malloc_hed0->lst, h->lst);
h->sz = sz;
h->sig = a_malloc_Sig;
h->lin = a_lin;
h->fil = a_fil;
h->serialNum = ++(a_malloc_hed0->serialNum);
a_malloc_hed0->lin++;
return h + 1;
#endif
}
a_static void a_free(_aDef_ void *p, intptr_t sz)
{
#if (a_DbgLv < 2)
(void) sz;
free(p);
#else
if (p == NULL) return;
a_malloc_Header *h = (a_malloc_Header *) p - 1;
if (h->sig != a_malloc_Sig)
a_errExit("%s(%d): free_: bad signature", a_...
if (h->sz != sz)
a_errExit("%s(%d): free_: bad size: sz=%d, a...
// h->sig = 0; h->serialNum = 0; // memsetがあるか...
a_List_rmv(h->lst->prv, h->lst->nxt);
a_malloc_hed0->lin--;
memset(h, 0x87, sz + sizeof (a_malloc_Header));
free(h);
#endif
}
a_static void *a_realloc(_aDef_ void *p, intptr_t sz0, ...
{
#if (a_DbgLv < 2)
(void) sz0;
p = realloc(p, sz1);
if (p == NULL)
a_errExit("realloc_: out of memory: sz1=%d");
return p;
#else
if (sz1 < 0)
a_errExit("%s(%d): realloc_ size error: sz1=...
if (p == NULL)
return a_malloc(_aThr, sz1);
a_malloc_Header *h = (a_malloc_Header *) p - 1;
if (h->sig != a_malloc_Sig)
a_errExit("%s(%d): realloc_: bad signature",...
if (h->sz != sz0)
a_errExit("%s(%d): realloc_: bad size: sz=%d...
h->sig = 0;
intptr_t sn = h->serialNum;
h->serialNum = 0;
a_List *prv = h->lst->prv;
a_List *nxt = h->lst->nxt;
a_List_rmv(prv, nxt);
#if 0
a_malloc_Header *h1 = (a_malloc_Header *) reallo...
// これだと古い領域を利用させないためのmemse...
if (h1 == NULL)
a_errExit("%s(%d): realloc_: out of memory: ...
#elif 1
a_malloc_Header *h1 = h;
if (sz0 > sz1)
memset(((char *) h) + sz1 + sizeof (a_malloc...
if (sz0 < sz1) {
h1 = malloc(sz1 + sizeof (a_malloc_Header));
if (h1 == NULL)
a_errExit("%s(%d): realloc_: out of memo...
memcpy(h1, h, sz0 + sizeof (a_malloc_Header));
memset(h, 0x87, sz0 + sizeof (a_malloc_Heade...
free(h);
memset(((char *) h1) + sz0 + sizeof (a_mallo...
}
#endif
a_List_add(prv, h1->lst, nxt);
h1->sig = a_malloc_Sig;
h1->serialNum = sn;
h1->sz = sz1;
// h1->lin = a_lin; h1->fil = a_fil; // reallocした...
return h1 + 1;
#endif
}
a_static void a_malloc_debugList(_aDef)
{
#if (a_DbgLv >= 2)
fprintf(stderr, "%s(%d): malloc_debugList()\n", ...
if (a_malloc_hed0->lst->prv != NULL) {
a_List *t = a_malloc_hed0->lst->nxt;
for (;;) {
a_malloc_Header *h = (a_malloc_Header *)...
if (h->sz < 0) break;
fprintf(stderr, " [p:%08x sz:%d / %s(%d...
t = t->nxt;
}
}
#endif
}
a_class(a_DbgObjInf) { intptr_t tblIdx, sig; };
a_class(a_DbgObjInfTbl) { intptr_t prv, nxt, lin; const ...
a_static a_DbgObjInfTbl *a_DbgObjInfTbl_p;
a_static intptr_t a_DbgObjInfTbl_nxt = -1, a_DbgObjInfTb...
a_static int64_t a_DbgObjInfTbl_sn = 0;
a_static void a_DbgObjInfTbl_extSiz()
{
intptr_t i0 = a_DbgObjInfTbl_n1, i1, i;
if (a_DbgObjInfTbl_n1 == 0) {
a_DbgObjInfTbl_n1 = 256;
a_DbgObjInfTbl_p = malloc(a_DbgObjInfTbl_n1 * si...
} else {
a_DbgObjInfTbl_n1 <<= 1;
a_DbgObjInfTbl_p = realloc(a_DbgObjInfTbl_p, a_D...
}
i1 = a_DbgObjInfTbl_n1;
if (a_DbgObjInfTbl_p == NULL)
a_errExit("a_DbgObjInfTbl_extSiz: out of memory:...
for (i = i0; i < i1; i++) {
a_DbgObjInfTbl_p[i].nxt = i + 1;
a_DbgObjInfTbl_p[i].lin = -1;
}
a_DbgObjInfTbl_p[i1 - 1].nxt = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = i0;
if (a_DbgObjInfTbl_nxt == 0) {
a_DbgObjInfTbl_nxt = 1;
a_DbgObjInfTbl_p[0].prv = 0;
a_DbgObjInfTbl_p[0].nxt = 0;
}
}
a_static void a_DbgObjInf_ini(const char *a_fil, int a_l...
{
if (a_DbgObjInfTbl_nxt < 0) a_DbgObjInfTbl_extSiz();
intptr_t i = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = a_DbgObjInfTbl_p[i].nxt;
a_DbgObjInfTbl_p[i].lin = a_lin;
a_DbgObjInfTbl_p[i].nam = nam;
a_DbgObjInfTbl_p[i].fil = a_fil;
a_DbgObjInfTbl_p[i].sn = a_DbgObjInfTbl_sn++;
a_DbgObjInfTbl_n++;
if (w->sig == a_malloc_Sig && 0 < w->tblIdx && w->tb...
a_errExit("%s(%d): a_DbgObjInf_ini: bad signatur...
w->tblIdx = i;
w->sig = a_malloc_Sig;
intptr_t p = a_DbgObjInfTbl_p[0].prv;
a_DbgObjInfTbl_p[p].nxt = i;
a_DbgObjInfTbl_p[i].prv = p;
a_DbgObjInfTbl_p[i].nxt = 0;
a_DbgObjInfTbl_p[0].prv = i;
}
a_static void a_DbgObjInf_din(const char *a_fil, int a_l...
{
if (w->sig != a_malloc_Sig)
a_errExit("%s(%d): a_DbgObjInf_din: bad signatur...
w->sig = 0;
intptr_t i = w->tblIdx;
a_DbgObjInfTbl_p[i].lin = -1;
a_DbgObjInfTbl_n--;
intptr_t p = a_DbgObjInfTbl_p[i].prv, n = a_DbgObjIn...
a_DbgObjInfTbl_p[p].nxt = n;
a_DbgObjInfTbl_p[n].prv = p;
a_DbgObjInfTbl_p[i].nxt = a_DbgObjInfTbl_nxt;
a_DbgObjInfTbl_nxt = i;
}
a_static void a_DbgObjInfTbl_debugList(_aDef)
{
#if (a_DbgLv >= 2)
fprintf(stderr, "%s(%d): DbgObjInfTbl_debugList(...
intptr_t i = a_DbgObjInfTbl_p[0].nxt;
while (i > 0) {
fprintf(stderr, " [%s / %s(%d)]\n", a_DbgOb...
i = a_DbgObjInfTbl_p[i].nxt;
}
#endif
}
** (99) 更新履歴
-2026.04.23(木) 初版
ページ名: