Skip to content

Commit

Permalink
Borrow signature free and reset from CallContext
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 27, 2012
1 parent 0e76dec commit 2798736
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/call/signature.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Parrot_Signature*
Parrot_pcc_signature_new(PARROT_INTERP) Parrot_pcc_signature_new(PARROT_INTERP)
{ {
Parrot_Signature *sig = (Parrot_Signature *)Parrot_gc_allocate_fixed_size_storage(interp, sizeof(Parrot_Signature)); Parrot_Signature *sig = (Parrot_Signature *)Parrot_gc_allocate_fixed_size_storage(interp, sizeof(Parrot_Signature));
memset(sig, 1, sizeof (Parrot_Signature));


return sig; return sig;
} }
Expand All @@ -178,9 +179,25 @@ Free Signature


PARROT_EXPORT PARROT_EXPORT
void void
Parrot_pcc_signature_free(PARROT_INTERP, ARGFREE(Parrot_Signature *sig)) Parrot_pcc_signature_free(PARROT_INTERP, ARGFREE(Parrot_Signature *self))
{ {
Parrot_gc_free_fixed_size_storage(interp, sizeof(Parrot_Signature), sig); if (self->allocated_positionals) {
Pcc_cell *c;

if (self->allocated_positionals > 8)
Parrot_gc_free_memory_chunk(interp, self->positionals);
else
Parrot_gc_free_fixed_size_storage(interp,
self->allocated_positionals * sizeof (Pcc_cell), self->positionals);
}

if (self->hash) {
parrot_hash_iterate(self->hash,
FREE_CELL(interp, (Pcc_cell *)_bucket->value););
Parrot_hash_destroy(interp, self->hash);
}

Parrot_gc_free_fixed_size_storage(interp, sizeof(Parrot_Signature), self);
} }


/* /*
Expand All @@ -192,8 +209,17 @@ Reset Signature for reuse.
*/ */
PARROT_EXPORT PARROT_EXPORT
void void
Parrot_pcc_signature_reset(PARROT_INTERP, ARGIN(Parrot_Signature *sig)) Parrot_pcc_signature_reset(PARROT_INTERP, ARGIN(Parrot_Signature *self))
{ {
/* Don't free positionals. Just reuse them */
self->num_positionals = 0;

if (self->hash) {
parrot_hash_iterate(self->hash,
FREE_CELL(interp, (Pcc_cell *)_bucket->value););
Parrot_hash_destroy(interp, self->hash);
self->hash = NULL;
}
} }




Expand Down

0 comments on commit 2798736

Please sign in to comment.