示例#1
0
int
main (void)
{
  gsl_block * b = gsl_block_alloc (100);
  
  printf ("length of block = %u\n", b->size);
  printf ("block data address = %#x\n", b->data);

  gsl_block_free (b);
  return 0;
}
示例#2
0
gsl_vector *gsl_vector_alloc (const size_t n)
{
 
  gsl_block * block;
  gsl_vector * v;

  if (n == 0)
    {
      bpm_error("vector length n must be positive integer in gsl_vector_alloc(...)",
		__FILE__, __LINE__ );
      return NULL;
    }

  v = (gsl_vector*) malloc (sizeof (gsl_vector));

  if (v == 0)
    {
      bpm_error("failed to allocate space for vector struct in gsl_vector_alloc(...)",
		__FILE__, __LINE__ );
      return NULL;
    }

  block = gsl_block_alloc(n);

  if (block == 0)
    {
      free (v) ;
      bpm_error("failed to allocate space for block in gsl_vector_alloc(...)",
		__FILE__, __LINE__ );
      return NULL;
    }
      
  v->data = block->data ;
  v->size = n;
  v->stride = 1;
  v->block = block;
  v->owner = 1;

  return v;
}