>>101540105
in honor of dumper-kun (who has thankfully kept the thread cleaner than usual by not talking about the nuances of malloc for 82 replies) i have written a registry dumper for TempleOS, not even sure if i could call it one since all it does is expand DolDoc trees so you can see every entry, but it still counts as "dump" i guess
U8 *MemMCat(U8 *a,I64 i,U8 *b,I64 j) {
U8 *new,*orig=NULL;
if (MSize(a)<i+j) {
new=MAlloc(2*(i+j));
MemCpy(new,a,i);
orig=a;
a=new;
}
MemCpy(a+i,b,j);
Free(orig);
return a;
}
U8 *StrMCat(U8 *a,U8 *b) {
return MemMCat(a,StrLen(a),b,StrLen(b)+1);
}
U8 *StrSwp(U8 *s,U8 *what,U8 *with,Bool free=TRUE) {
U8 *cur=s,*res=CAlloc(1),*match;
I64 what_len=StrLen(what),len=StrLen(with),cur_len=0;
while (TRUE) {
if (match=StrMatch(what,cur)) {
//not invoking strlen->100x speedup
//no strlen in hot loops!
res=MemMCat(res,cur_len,cur,match-cur);
cur_len+=match-cur;
res=MemMCat(res,cur_len,with,len);
cur_len+=len;
cur=match+what_len;
} else {
StrMCat(res,cur);
break;
}
}
if (free) Free(s);
return res;
}
U0 RegDump(U8 *reg="~/Registry.HC") {
U8 *s=FileRead(reg);
if (!s) return;
s=StrSwp(s,"\dTR,\"","\dTR-C,\"");
"\dHL,1\d%s\dHL,0\d\n",s;
Free(s);
}
RegDump;