/* * call-seq: * pq.clone -> pq_clone * * Returns a shallow clone of the priority queue. That is only the priority * queue is cloned, its contents are not cloned. */ static VALUE frb_pq_clone(VALUE self) { PriQ *pq, *new_pq = ALLOC(PriQ); GET_PQ(pq, self); memcpy(new_pq, pq, sizeof(PriQ)); new_pq->heap = ALLOC_N(VALUE, new_pq->mem_capa); memcpy(new_pq->heap, pq->heap, sizeof(VALUE) * (new_pq->size + 1)); return Data_Wrap_Struct(cPriorityQueue, &frb_pq_mark, &frb_pq_free, new_pq); }