belle_sip_list_t* belle_sip_list_copy_with_data(const belle_sip_list_t* list, void* (*copyfunc)(void*)){ belle_sip_list_t* copy=NULL; const belle_sip_list_t* iter; for(iter=list;iter!=NULL;iter=belle_sip_list_next(iter)){ copy=belle_sip_list_append(copy,copyfunc(iter->data)); } return copy; }
MSList *ms_list_copy_with_data(const MSList *list, void *(*copyfunc)(void *)){ MSList *copy=NULL; const MSList *iter; for(iter=list;iter!=NULL;iter=ms_list_next(iter)){ copy=ms_list_append(copy,copyfunc(iter->data)); } return copy; }
bctbx_list_t* bctbx_list_copy_with_data(const bctbx_list_t* list, bctbx_list_copy_func copyfunc) { bctbx_list_t* copy=NULL; const bctbx_list_t* iter; for(iter=list; iter!=NULL; iter=bctbx_list_next(iter)) { copy=bctbx_list_append(copy,copyfunc(iter->data)); } return copy; }
static void copy_tiles(unsigned *permutation) { unsigned src_tile, src_buf_idx, src_x, src_y; unsigned dst_tile, dst_buf_idx, dst_x, dst_y; struct scratch_buf *src_buf, *dst_buf; int i, idx; for (i = 0; i < num_total_tiles; i++) { /* tile_permutation is independent of current_permutation, so * abuse it to randomize the order of the src bos */ idx = tile_permutation[i]; src_buf_idx = idx / options.tiles_per_buf; src_tile = idx % options.tiles_per_buf; src_buf = &buffers[current_set][src_buf_idx]; tile2xy(src_buf, src_tile, &src_x, &src_y); dst_buf_idx = permutation[idx] / options.tiles_per_buf; dst_tile = permutation[idx] % options.tiles_per_buf; dst_buf = &buffers[target_set][dst_buf_idx]; tile2xy(dst_buf, dst_tile, &dst_x, &dst_y); if (options.trace_tile == i) printf("copying tile %i from %i (%i, %i) to %i (%i, %i)", i, tile_permutation[i], src_buf_idx, src_tile, permutation[idx], dst_buf_idx, dst_tile); if (options.no_hw) { cpucpy2d(src_buf->data, src_buf->stride / sizeof(uint32_t), src_x, src_y, dst_buf->data, dst_buf->stride / sizeof(uint32_t), dst_x, dst_y, i); } else { next_copyfunc(i); copyfunc(src_buf, src_x, src_y, dst_buf, dst_x, dst_y, i); } } intel_batchbuffer_flush(batch); }
/* Perform an exact copy of the entire set, returning the new set. msize * specifies the size of each member. If copyfunc is non-NULL, it is called * instead to copy each member. Returns NULL if out of memory condition * occurs. */ xaset_t *xaset_copy(pool *p, xaset_t *set, size_t msize, XASET_MCOPY copyfunc) { xaset_t *new_set; xasetmember_t *n, *m, **pos; if (set == NULL) { errno = EINVAL; return NULL; } if (!copyfunc && !msize) { errno = EINVAL; return NULL; } p = (p ? p : set->pool); new_set = xaset_create(p, set->xas_compare); if (new_set == NULL) return NULL; pos = &new_set->xas_list; /* NOTE: xaset_insert_sort is not used here for performance reasons. */ for (m = set->xas_list; m; m = m->next) { n = copyfunc ? copyfunc(m) : (xasetmember_t *) palloc(p, msize); if (!n) return NULL; /* Could clean up here */ if (!copyfunc) memcpy(n, m, msize); /* Create links */ n->prev = *pos; n->next = NULL; if (*pos) pos = &(*pos)->next; *pos = n; } return new_set; }