vmx: avoid strdup() register names for register cache
If we tokenize the register file contents in a static buffer, we can avoid having to duplicate the register names. All callers to rpoke() provide constant register arguments so they also do not need to be duplicated.
This commit is contained in:
parent
67eac97a81
commit
532c7479e9
1 changed files with 7 additions and 9 deletions
|
@ -106,9 +106,9 @@ vmxsetup(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { RCENT = 256 };
|
enum { RCENT = 256 };
|
||||||
char *rcname[RCENT];
|
static char *rcname[RCENT];
|
||||||
uvlong rcval[RCENT];
|
static uvlong rcval[RCENT];
|
||||||
uvlong rcvalid[(RCENT+63)/64], rcdirty[(RCENT+63)/64];
|
static uvlong rcvalid[(RCENT+63)/64], rcdirty[(RCENT+63)/64];
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rclookup(char *n)
|
rclookup(char *n)
|
||||||
|
@ -149,7 +149,7 @@ rcflush(int togo)
|
||||||
static void
|
static void
|
||||||
rcload(void)
|
rcload(void)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
static char buf[4096];
|
||||||
char *p, *q, *f[2];
|
char *p, *q, *f[2];
|
||||||
int nf;
|
int nf;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
@ -166,14 +166,12 @@ rcload(void)
|
||||||
nf = tokenize(p, f, nelem(f));
|
nf = tokenize(p, f, nelem(f));
|
||||||
p = q + 1;
|
p = q + 1;
|
||||||
if(nf < 2) break;
|
if(nf < 2) break;
|
||||||
free(rcname[i]);
|
rcname[i] = f[0];
|
||||||
rcname[i] = strdup(f[0]);
|
|
||||||
rcval[i] = strtoull(f[1], nil, 0);
|
rcval[i] = strtoull(f[1], nil, 0);
|
||||||
rcvalid[i>>6] |= 1ULL<<(i&63);
|
rcvalid[i>>6] |= 1ULL<<(i&63);
|
||||||
}
|
}
|
||||||
for(; i < nelem(rcname); i++){
|
for(; i < nelem(rcname); i++){
|
||||||
free(rcname[i]);
|
rcname[i] = nil;
|
||||||
rcname[i] = 0;
|
|
||||||
rcvalid[i>>6] &= ~(1ULL<<(i&63));
|
rcvalid[i>>6] &= ~(1ULL<<(i&63));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +202,7 @@ rpoke(char *reg, uvlong val, int clean)
|
||||||
}
|
}
|
||||||
for(i = 0; i < nelem(rcname); i++)
|
for(i = 0; i < nelem(rcname); i++)
|
||||||
if(rcname[i] == nil){
|
if(rcname[i] == nil){
|
||||||
rcname[i] = strdup(reg);
|
rcname[i] = reg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(i < nelem(rcname));
|
assert(i < nelem(rcname));
|
||||||
|
|
Loading…
Reference in a new issue