Beispiel #1
0
int8_t
resize_Vector(Vector * vec, size_t size)
{
  void *ptr;
  size_t offset = size * O(vec);

  CHECK_VARN(vec, EINVAL);
  CHECK_VARA(ptr = AMMalloc(offset),EALLOCF);
  ARR_COPY_WRAP(Vector,ptr,vec,size);
  /*offset = S(vec) * O(vec);
  if(M(vec)) {
	  if(S(vec) == 0) {
		  printf("%d\n",__LINE__);
	  } else if(H(vec) < T(vec)) {
		  printf("%d\n",__LINE__);
		  memcpy(ptr,H(vec),((char *)T(vec) - (char *)H(vec)));
	  } else if((void *)((char *)(H(vec)) + offset) < vec->end) {
		  printf("%d\n",__LINE__);
		  memcpy(ptr,H(vec),offset);
	  } else {
		  ptrdiff_t spaces = ((char *)vec->end - (char *)H(vec));
		  memcpy(ptr,H(vec),(size_t)spaces);
		  memcpy((char *)(ptr + spaces),M(vec),O(vec) * (S(vec) - spaces/O(vec)));
	  }
	  AMFree(M(vec));
  }*/
  ARR_SETUP_POINTERS(Vector,ptr,vec,size);
  return SUCCESS;
}
Beispiel #2
0
int8_t resize_DequeVector(DequeVector *deque,size_t size) {
	void *ptr = NULL;
	CHECK_VARN(deque,EINVAL);
	CHECK_VARA(ptr = malloc(size * O(deque)),EALLOCF);
	
	ARR_COPY_WRAP(DequeVector,ptr,deque,size);

	ARR_SETUP_POINTERS(DequeVector,ptr,deque,size);
	return 0;
}
Beispiel #3
0
int8_t resize_StackVector(StackVector *stack,size_t size) {
	void *ptr = NULL;
	CHECK_VARN(stack,EINVAL);
	CHECK_VARA(ptr = malloc(size * O(stack)),EALLOCF);
	
	ARR_COPY_WRAP(StackVector,ptr,stack,size);

	ARR_SETUP_POINTERS(StackVector,ptr,stack,size);

	return 0;
}