aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Anvin <hpa@tazenda.(none)>2005-12-08 14:54:49 -0800
committerPeter Anvin <hpa@tazenda.(none)>2005-12-08 14:54:49 -0800
commitc241022ab4254ad66b5652010c06bf983f75d7c1 (patch)
tree1a2a6bbee1b4397b51800c82c7d9cff911e77c0a
parenta9d918f61492b91efd89dc8119a57a1a010e5376 (diff)
downloadlibucd-c241022ab4254ad66b5652010c06bf983f75d7c1.tar.gz
Don't hold the cache lock while freeing an old entry.
-rwxr-xr-xgencache.pl16
1 files changed, 10 insertions, 6 deletions
diff --git a/gencache.pl b/gencache.pl
index fdedae6..0d7bb18 100755
--- a/gencache.pl
+++ b/gencache.pl
@@ -61,15 +61,19 @@ for ( $i = 0 ; $i < $associativity ; $i++ ) {
print GEN "\tunlock_cache(r); \\\n";
print GEN "\tucd = _libucd_character_data_raw(u); \\\n";
-print GEN "\tlock_cache(r); \\\n";
-print GEN "\tif ( r->e[$maxent].ucd ) \\\n";
-print GEN "\t\tunicode_character_put(r->e[$maxent].ucd); \\\n";
+print GEN "\t{ \\\n";
+print GEN "\t\tconst struct unicode_character_data *olducd; \\\n";
+print GEN "\t\tlock_cache(r); \\\n";
+print GEN "\t\tolducd = r->e[$maxent].ucd; \\\n";
for ( $j = $maxent ; $j > 0 ; $j-- ) {
$jm1 = $j-1;
- print GEN "\tr->e[$j] = r->e[$jm1]; \\\n";
+ print GEN "\t\tr->e[$j] = r->e[$jm1]; \\\n";
}
-print GEN "\tr->e[0].ucs = u; r->e[0].ucd = ucd; \\\n";
-print GEN "\tunlock_cache(r); \\\n";
+print GEN "\t\tr->e[0].ucs = u; r->e[0].ucd = ucd; \\\n";
+print GEN "\t\tunlock_cache(r); \\\n";
+print GEN "\t\tif (olducd) \\\n";
+print GEN "\t\t\tunicode_character_put(olducd); \\\n";
+print GEN "\t} \\\n";
print GEN "\treturn ucd; \\\n";
print GEN "\n";