Don't add current_arch_start more than once.

Fix ordering of ALIGN with respect to saving block_ptr; add another ALIGN
    to fcfs.c.
reviewed by: plam
This commit is contained in:
Patrick Lam 2005-11-17 15:43:39 +00:00
parent 8e351527bb
commit 1c5b6345b9
6 changed files with 39 additions and 8 deletions

View File

@ -1,3 +1,19 @@
2005-11-17 Andreas Schwab <schwab@suse.de>
reviewed by: plam
* src/fccache.c (FcGlobalCacheSave):
Don't add current_arch_start more than once.
2005-11-16 Patrick Lam <plam@mit.edu>
* src/fccharset.c (FcCharSetDistributeBytes, FcCharSetUnserialize):
* src/fcfs.c (FcFontSetUnserialize):
* src/fcname.c (FcObjectDistributeBytes, FcObjectUnserialize):
* src/fcpat.c (FcStrUnserialize):
Fix ordering of ALIGN with respect to saving block_ptr; add
another ALIGN to fcfs.c.
2005-11-16 Patrick Lam <plam@mit.edu> 2005-11-16 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcDirCacheProduce) * src/fccache.c (FcDirCacheProduce)

View File

@ -367,7 +367,7 @@ FcGlobalCacheSave (FcGlobalCache *cache,
{ {
truncate_to += strlen(dir->name) + 1; truncate_to += strlen(dir->name) + 1;
truncate_to += sizeof (FcCache); truncate_to += sizeof (FcCache);
truncate_to = FcCacheNextOffset (current_arch_start + truncate_to); truncate_to = FcCacheNextOffset (truncate_to);
truncate_to += dir->metadata.count; truncate_to += dir->metadata.count;
} }
truncate_to -= current_arch_start; truncate_to -= current_arch_start;

View File

@ -1379,20 +1379,20 @@ FcCharSetDistributeBytes (FcCache * metadata, void * block_ptr)
if (!FcCharSetEnsureBank(bi)) if (!FcCharSetEnsureBank(bi))
return 0; return 0;
charsets[bi] = (FcCharSet *)block_ptr;
block_ptr = ALIGN (block_ptr, FcCharSet); block_ptr = ALIGN (block_ptr, FcCharSet);
charsets[bi] = (FcCharSet *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof (FcCharSet) * charset_count)); (sizeof (FcCharSet) * charset_count));
numbers[bi] = (FcChar16 *)block_ptr;
block_ptr = ALIGN (block_ptr, FcChar16); block_ptr = ALIGN (block_ptr, FcChar16);
numbers[bi] = (FcChar16 *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(FcChar16) * charset_numbers_count)); (sizeof(FcChar16) * charset_numbers_count));
leaves[bi] = (FcCharLeaf *)block_ptr;
block_ptr = ALIGN (block_ptr, FcCharLeaf); block_ptr = ALIGN (block_ptr, FcCharLeaf);
leaves[bi] = (FcCharLeaf *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(FcCharLeaf) * charset_leaf_count)); (sizeof(FcCharLeaf) * charset_leaf_count));
leaf_idx[bi] = (int *)block_ptr;
block_ptr = ALIGN (block_ptr, int); block_ptr = ALIGN (block_ptr, int);
leaf_idx[bi] = (int *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(int) * charset_leaf_idx_count)); (sizeof(int) * charset_leaf_idx_count));
@ -1438,15 +1438,19 @@ FcCharSetUnserialize (FcCache metadata, void *block_ptr)
if (!FcCharSetEnsureBank(bi)) if (!FcCharSetEnsureBank(bi))
return 0; return 0;
block_ptr = ALIGN (block_ptr, FcCharSet);
charsets[bi] = (FcCharSet *)block_ptr; charsets[bi] = (FcCharSet *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof (FcCharSet) * metadata.charset_count)); (sizeof (FcCharSet) * metadata.charset_count));
block_ptr = ALIGN (block_ptr, FcChar16);
numbers[bi] = (FcChar16 *)block_ptr; numbers[bi] = (FcChar16 *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(FcChar16) * metadata.charset_numbers_count)); (sizeof(FcChar16) * metadata.charset_numbers_count));
block_ptr = ALIGN (block_ptr, FcCharLeaf);
leaves[bi] = (FcCharLeaf *)block_ptr; leaves[bi] = (FcCharLeaf *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(FcCharLeaf) * metadata.charset_leaf_count)); (sizeof(FcCharLeaf) * metadata.charset_leaf_count));
block_ptr = ALIGN (block_ptr, int);
leaf_idx[bi] = (int *)block_ptr; leaf_idx[bi] = (int *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof(int) * metadata.charset_leaf_idx_count)); (sizeof(int) * metadata.charset_leaf_idx_count));

View File

@ -155,6 +155,7 @@ FcFontSetUnserialize(FcCache metadata, FcFontSet * s, void * block_ptr)
int nfont; int nfont;
int i, n; int i, n;
block_ptr = ALIGN (block_ptr, int);
nfont = *(int *)block_ptr; nfont = *(int *)block_ptr;
block_ptr = (int *)block_ptr + 1; block_ptr = (int *)block_ptr + 1;
@ -174,10 +175,17 @@ FcFontSetUnserialize(FcCache metadata, FcFontSet * s, void * block_ptr)
if (nfont > 0) if (nfont > 0)
{ {
FcPattern * p = (FcPattern *)block_ptr; FcPattern * p = (FcPattern *)block_ptr;
block_ptr = FcPatternUnserialize (metadata, block_ptr);
/* The following line is a bit counterintuitive. The usual
* convention is that FcPatternUnserialize is responsible for
* aligning the FcPattern. However, the FontSet also stores
* the FcPatterns in its own array, so we need to align here
* too. */
p = ALIGN(p, FcPattern);
for (i = 0; i < nfont; i++) for (i = 0; i < nfont; i++)
s->fonts[n + i] = p+i; s->fonts[n + i] = p+i;
block_ptr = FcPatternUnserialize (metadata, block_ptr);
block_ptr = FcObjectUnserialize (metadata, block_ptr); block_ptr = FcObjectUnserialize (metadata, block_ptr);
} }

View File

@ -341,11 +341,11 @@ FcObjectNeededBytesAlign (void)
void * void *
FcObjectDistributeBytes (FcCache * metadata, void * block_ptr) FcObjectDistributeBytes (FcCache * metadata, void * block_ptr)
{ {
*(int *)block_ptr = biggest_known_ntypes;
block_ptr = ALIGN (block_ptr, int); block_ptr = ALIGN (block_ptr, int);
*(int *)block_ptr = biggest_known_ntypes;
block_ptr = (int *) block_ptr + 1; block_ptr = (int *) block_ptr + 1;
biggest_ptr = block_ptr;
block_ptr = ALIGN (block_ptr, char); block_ptr = ALIGN (block_ptr, char);
biggest_ptr = block_ptr;
block_ptr = (char *) block_ptr + biggest_known_count; block_ptr = (char *) block_ptr + biggest_known_count;
return block_ptr; return block_ptr;
} }
@ -367,6 +367,7 @@ FcObjectUnserialize (FcCache metadata, void *block_ptr)
{ {
int new_biggest; int new_biggest;
new_biggest = *(int *)block_ptr; new_biggest = *(int *)block_ptr;
block_ptr = ALIGN (block_ptr, int);
block_ptr = (int *) block_ptr + 1; block_ptr = (int *) block_ptr + 1;
if (biggest_known_ntypes < new_biggest) if (biggest_known_ntypes < new_biggest)
{ {
@ -409,6 +410,7 @@ FcObjectUnserialize (FcCache metadata, void *block_ptr)
biggest_known_ntypes = new_biggest; biggest_known_ntypes = new_biggest;
biggest_known_types = (const FcObjectType *)bn; biggest_known_types = (const FcObjectType *)bn;
} }
block_ptr = ALIGN (block_ptr, char);
block_ptr = (char *) block_ptr + biggest_known_count; block_ptr = (char *) block_ptr + biggest_known_count;
return block_ptr; return block_ptr;
} }

View File

@ -1963,6 +1963,7 @@ FcStrUnserialize (FcCache metadata, void *block_ptr)
return 0; return 0;
FcMemAlloc (FC_MEM_STRING, sizeof (char) * metadata.str_count); FcMemAlloc (FC_MEM_STRING, sizeof (char) * metadata.str_count);
block_ptr = ALIGN (block_ptr, FcChar8);
static_strs[bi] = (FcChar8 *)block_ptr; static_strs[bi] = (FcChar8 *)block_ptr;
block_ptr = (void *)((char *)block_ptr + block_ptr = (void *)((char *)block_ptr +
(sizeof (char) * metadata.str_count)); (sizeof (char) * metadata.str_count));