Skip to content

Commit

Permalink
[PMC] Make clone() in OrderedHash call pmc_new to ensure that the des…
Browse files Browse the repository at this point in the history
…tination

PMC gets initialized with the flag that says "Hey, I have custom mark() and
destroy() entries."

Fixes RT #46337.

git-svn-id: https://svn.parrot.org/parrot/trunk@22148 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed Oct 16, 2007
1 parent 415914a commit 7cab8ee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pmc/orderedhash.pmc
Expand Up @@ -542,26 +542,26 @@ the clone via integers has different indices, if items were deleted.
*/

PMC *clone() {
PMC *dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PMC *dest = pmc_new(INTERP, SELF->vtable->base_type);
Hash *hash = (Hash *)PMC_struct_val(SELF);
Hash *h_dest;
UINTVAL i;
void *valtmp;

parrot_new_pmc_hash_x(INTERP, dest, hash->entry_type,
hash->key_type, hash->compare, hash->hash_val);

h_dest = (Hash *)PMC_struct_val(dest);

for (i = 0; i <= hash->mask; i++) {
HashBucket *b = hash->bs + i;
void *key = b->key;
HashBucket *b = hash->bs + i;
void *key = b->key;
void *valtmp = b->value;

if (!key)
continue;

valtmp = VTABLE_clone(INTERP, (PMC *)b->value);
parrot_hash_put(INTERP, h_dest, key, valtmp);
parrot_hash_put(INTERP, h_dest, key,
(void *)VTABLE_clone(INTERP, (PMC *)valtmp));
}

return dest;
Expand Down

0 comments on commit 7cab8ee

Please sign in to comment.