当前位置: 首页>>代码示例>>C++>>正文


C++ MEM_CHECK函数代码示例

本文整理汇总了C++中MEM_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ MEM_CHECK函数的具体用法?C++ MEM_CHECK怎么用?C++ MEM_CHECK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MEM_CHECK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: btreeCreateNodeBlock

void *
btreeCreateNodeBlock(GdbBlock *block, void *extra)
{
    BTreeNode *node;
    BTree *tree;

    tree = (BTree *)extra;

    MEM_CHECK(node = (BTreeNode *)SAFE_MALLOC(sizeof(BTreeNode), LOC_BTREE_0166));
    memset(node, 0, sizeof(BTreeNode));

    node->tree  = tree;
    node->block = block;

    /*comment: when reach here, we have no idea about keyCount, hence alloc children/keySizes/keys as the max possible num: the order*/

    MEM_CHECK(node->children = (offset_t *)SAFE_MALLOC(tree->order * sizeof(offset_t), LOC_BTREE_0167));
    memset(node->children, 0, tree->order * sizeof(offset_t));


    MEM_CHECK(node->keySizes = (uint16_t *)SAFE_MALLOC((tree->order - 1) * sizeof(uint16_t), LOC_BTREE_0168));
    memset(node->keySizes, 0, (tree->order - 1)  * sizeof(uint16_t));


    MEM_CHECK(node->keys = (uint8_t **)SAFE_MALLOC((tree->order - 1) * sizeof(uint8_t *), LOC_BTREE_0169));
    memset(node->keys, 0, (tree->order - 1) * sizeof(uint8_t *));

    return node;
}
开发者ID:petercloud,项目名称:RFS,代码行数:29,代码来源:btree_node.c

示例2: assert

void PetscMatrix::alloc() {
  _F_
#ifdef WITH_PETSC
  assert(pages != NULL);

  // calc nnz
  int *nnz_array = new int[size];
  MEM_CHECK(nnz_array);

  // fill in nnz_array
  int aisize = get_num_indices();
  int *ai = new int[aisize];
  MEM_CHECK(ai);

  // sort the indices and remove duplicities, insert into ai
  int pos = 0;
  for (unsigned int i = 0; i < size; i++) {
    nnz_array[i] = sort_and_store_indices(pages[i], ai + pos, ai + aisize);
    pos += nnz_array[i];
  }
  // stote the number of nonzeros
  nnz = pos;
  delete [] pages; pages = NULL;
  delete [] ai;

  //
  MatCreateSeqAIJ(PETSC_COMM_SELF, size, size, 0, nnz_array, &matrix);
//	MatSetOption(matrix, MAT_ROW_ORIENTED);
//	MatSetOption(matrix, MAT_ROWS_SORTED);

  delete [] nnz_array;

  inited = true;
#endif
}
开发者ID:alieed,项目名称:hermes,代码行数:35,代码来源:petsc.cpp

示例3: assert

void SuperLUMatrix::alloc()
{
  _F_
  assert(pages != NULL);
  assert(size > 0);
  
  // Initialize the arrays Ap and Ai.
  Ap = new int [size + 1];
  MEM_CHECK(Ap);
  int aisize = get_num_indices();
  Ai = new int [aisize];
  MEM_CHECK(Ai);
  
  // sort the indices and remove duplicities, insert into Ai
  int i, pos = 0;
  for (i = 0; i < size; i++) {
    Ap[i] = pos;
    pos += sort_and_store_indices(pages[i], Ai + pos, Ai + aisize);
  }
  Ap[i] = pos;
  
  delete [] pages;
  pages = NULL;
  
  nnz = Ap[size];

  Ax = new slu_scalar [nnz];
  memset(Ax, 0, sizeof(slu_scalar) * nnz);
}
开发者ID:dugankevin,项目名称:hermes,代码行数:29,代码来源:superlu.cpp

示例4: assert

void UMFPackMatrix::alloc() {
	_F_
	assert(pages != NULL);

	// initialize the arrays Ap and Ai
	Ap = new int [size + 1];
	MEM_CHECK(Ap);
	int aisize = get_num_indices();
	Ai = new int [aisize];
	MEM_CHECK(Ai);

	// sort the indices and remove duplicities, insert into Ai
	int i, pos = 0;
	for (i = 0; i < size; i++) {
		Ap[i] = pos;
		pos += sort_and_store_indices(pages[i], Ai + pos, Ai + aisize);
	}
	Ap[i] = pos;

	delete [] pages;
	pages = NULL;

	Ax = new scalar [Ap[size]];
	MEM_CHECK(Ax);
	memset(Ax, 0, sizeof(scalar) * Ap[size]);
}
开发者ID:MathPhys,项目名称:hermes,代码行数:26,代码来源:umfpack.cpp

示例5: assert

void CSCMatrix::alloc() {
  _F_
  assert(pages != NULL);
  if (size <= 0)
      error("UMFPack failed, matrix size must be greater than 0.");

  // initialize the arrays Ap and Ai
  Ap = new int [size + 1];
  MEM_CHECK(Ap);
  int aisize = get_num_indices();
  Ai = new int [aisize];
  MEM_CHECK(Ai);

  // sort the indices and remove duplicities, insert into Ai
  unsigned int i;
  int pos = 0;
  for (i = 0; i < size; i++) {
    Ap[i] = pos;
    pos += sort_and_store_indices(pages[i], Ai + pos, Ai + aisize);
  }
  Ap[i] = pos;

  delete [] pages;
  pages = NULL;

  nnz = Ap[size];
  
  Ax = new scalar [nnz];
  MEM_CHECK(Ax);
  memset(Ax, 0, sizeof(scalar) * nnz);
}
开发者ID:schnepp,项目名称:hermes,代码行数:31,代码来源:umfpack_solver.cpp

示例6: assert

void RefMap::calc_face_normal(int iface, const int np, const QuadPt3D *pt, double *&nx, double *&ny, double *&nz) {
	_F_
	assert(mesh != NULL);

	double3x3 *m = get_ref_map(np, pt);

	nx = new double[np]; MEM_CHECK(nx);
	ny = new double[np]; MEM_CHECK(ny);
	nz = new double[np]; MEM_CHECK(nz);

	// FIXME: refactor this!
	// - it would be nice if calculation of normals would be based on the same algorithm for all elements
	//   e.g. to take a normal from ref. domain and transform it to the physical one
	int t_dir_1, t_dir_2; //directions of tangents ot the reference face such that t_dir_1 x t_dir_2 = outer normal
	switch (element->get_mode()) {
		case MODE_TETRAHEDRON: {
			const int *face_vtx = element->get_face_vertices(iface);
			Vertex vtx[Tri::NUM_VERTICES];
			for (int i = 0; i < element->get_num_vertices(); i++)
				vtx[i] = vertex[face_vtx[i]];

			Point3D v1 = { vtx[1].x - vtx[0].x, vtx[1].y - vtx[0].y, vtx[1].z - vtx[0].z };
			Point3D v2 = { vtx[2].x - vtx[0].x, vtx[2].y - vtx[2].y, vtx[2].z - vtx[0].z };
			Point3D n = normalize(cross_product(v1, v2));

			for (int i = 0; i < np; i++) {
				nx[i] = n.x;
				ny[i] = n.y;
				nz[i] = n.z;
			}
			} break;

		case MODE_HEXAHEDRON:
			switch (iface) {
				case 0: t_dir_1 = 2; t_dir_2 = 1; break;
				case 1: t_dir_1 = 1; t_dir_2 = 2; break;
				case 2: t_dir_1 = 0; t_dir_2 = 2; break;
				case 3: t_dir_1 = 2; t_dir_2 = 0; break;
				case 4: t_dir_1 = 1; t_dir_2 = 0; break;
				case 5: t_dir_1 = 0; t_dir_2 = 1; break;
			}
			for (int i = 0; i < np; i++) {
				Point3D tangent1 = { m[i][0][t_dir_1], m[i][1][t_dir_1], m[i][2][t_dir_1] };
				Point3D tangent2 = { m[i][0][t_dir_2], m[i][1][t_dir_2], m[i][2][t_dir_2] };
				Point3D normal = normalize(cross_product(tangent1, tangent2));

				nx[i] = normal.x;
				ny[i] = normal.y;
				nz[i] = normal.z;
			}
			break;

		case MODE_PRISM:
			EXIT(HERMES_ERR_NOT_IMPLEMENTED);
	}

	delete [] m;
}
开发者ID:aurelioarranz,项目名称:hermes,代码行数:58,代码来源:refmap.cpp

示例7: Epetra_Map

void EpetraMatrix::prealloc(unsigned int n)
{
  _F_
#ifdef HAVE_EPETRA
  this->size = n;
  // alloc trilinos structs
  std_map = new Epetra_Map(n, 0, seq_comm); MEM_CHECK(std_map);
  grph = new Epetra_CrsGraph(Copy, *std_map, 0); MEM_CHECK(grph);
#endif
}
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:10,代码来源:epetra.cpp

示例8: Epetra_CrsMatrix

void EpetraMatrix::alloc()
{
  _F_
#ifdef HAVE_EPETRA
  grph->FillComplete();
  // create the matrix
  mat = new Epetra_CrsMatrix(Copy, *grph); MEM_CHECK(mat);
#ifdef HERMES_COMMON_COMPLEX
  mat_im = new Epetra_CrsMatrix(Copy, *grph); MEM_CHECK(mat_im);
#endif
#endif
}
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:12,代码来源:epetra.cpp

示例9: f_sql_handles

/************************************************************************* 
 * f_sql_handles( void ) 
 *
 * returns an array containing the IDs of the currently opened connections
 *************************************************************************/
svalue_t *
f_sql_handles( svalue_t * argv, int argc )
{
#if ODBC_DEBUG & DEBUG_FUNC
   printf( "call f_sql_handles( )\n" );
#endif
   int  cnt, i;
   hDBC * tmp;

   vector_t    * vec;

   argv++;
   
   if ( !hODBCEnv )
      init_odbc_environment();
  
   if ( !hODBCEnv ) {
      put_number( argv, 0 );
      return( argv );
   }
   
   if ( !hODBCEnv->hDBCons ) {

      vec = allocate_array( 0 );
      MEM_CHECK( vec );

      put_array( argv, vec );
      return( argv );
   }

   tmp = hODBCEnv->hDBCons;
   cnt = 1;

   while( (tmp = tmp->next ) )
      cnt++;

   vec = allocate_array( cnt );
   MEM_CHECK( vec );

   tmp = hODBCEnv->hDBCons;
   for ( i = 0; i < cnt; ++i ) {
      put_number( vec->item + i, tmp->ID );
      tmp = tmp->next;
   }

   put_array( argv, vec );
#if ODBC_DEBUG & DEBUG_FUNC
   printf( "ret f_sql_handles( )\n" );
#endif
   return( argv );
}
开发者ID:Fuchur,项目名称:ldmud,代码行数:56,代码来源:pkg-odbc.c

示例10: fetch_into_mapping

static mapping_t * 
fetch_into_mapping( hDBC * handle )
{
   int       i;

   mapping_t  * map;   
   svalue_t  * key,
             * value;

   STORE_DOUBLE_USED;

   map = allocate_mapping( handle->colcnt, 1 );
   MEM_CHECK( map );
         
   for( i = 0; i < handle->colcnt; ++i ) {
      if ( !handle->columns[ i ] ) continue;

      //printf( " fetch_into_mapping[%2d] ", i );
      
      key = pxalloc( sizeof( svalue_t ) ); 
      MEM_CHECK( key );
         
      put_malloced_string( key, string_copy( handle->columns[ i ]->name ) );
         
      value = get_map_lvalue( map, key );
      MEM_CHECK( value );

      switch( handle->columns[ i ]->type ){
         case T_FLOAT:
            //printf( "float=%f\n",  handle->columns[ i ]->data.double_v );
            STORE_DOUBLE( value, *handle->columns[ i ]->data.double_v );

            value->type = T_FLOAT;
            break; 

         case T_NUMBER:
            //printf( "number=%d\n",  *handle->columns[ i ]->data.number_v );
            put_number( value, *handle->columns[ i ]->data.number_v );
            break;

         case T_STRING: 
         default      :
            //printf( "string=%s\n",  handle->columns[ i ]->data.string_v );
            put_malloced_string( value, string_copy(  handle->columns[ i ]->data.string_v ) );
            break;
      }
   }

   return( map );
}
开发者ID:Fuchur,项目名称:ldmud,代码行数:50,代码来源:pkg-odbc.c

示例11: rawFileOpen

RawFile * rawFileOpen(const uint8_t *file_name, const int flags, const uint32_t file_size, const word_t cdfs_md_id)
{
    MEM_CHECK(file_name);

    if(flags & O_RDWR)
    {
        RawFile   * raw_file;
#if 0
        CBYTES    * cbytes;
        CSTRING   * fname_cstr;
#endif
        raw_file = rawFileNew(file_name, -1, O_RDWR, file_size, cdfs_md_id);
        if(NULL == raw_file)
        {
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawFileOpen: new raw file failed\n");
            return NULL;
        }

        if(RAW_FILE_SUCC != rawFileLoad(raw_file))
        {
            dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT, "error:rawFileOpen: load %s failed\n", (char *)file_name);
            raw_file->fd = -1;
            rawFileFree(raw_file);
            return NULL;
        }
        return raw_file;
    }

    if(flags & O_CREAT)
    {
        return rawFileCreate(file_name, file_size, cdfs_md_id);
    }

    return NULL;
}
开发者ID:petercloud,项目名称:RFS,代码行数:35,代码来源:raw_data.c

示例12: MEM_CHECK

double *RefMap::get_jacobian(const int np, const QuadPt3D *pt, bool trans) {
	_F_

	double *jac = new double[np]; MEM_CHECK(jac);
	if (is_const_jacobian) {
		if (trans)
			for (int i = 0; i < np; i++)
				jac[i] = const_jacobian * pt[i].w;
		else
			for (int i = 0; i < np; i++)
				jac[i] = const_jacobian;
	}
	else {
		double3x3 *m = get_ref_map(np, pt);

		double trj = get_transform_jacobian();
		if (trans)
			for (int i = 0; i < np; i++)
				jac[i] = det(m[i]) * trj * pt[i].w;
		else
			for (int i = 0; i < np; i++)
				jac[i] = det(m[i]) * trj;

		delete [] m;
	}

	return jac;
}
开发者ID:aurelioarranz,项目名称:hermes,代码行数:28,代码来源:refmap.cpp

示例13: MEM_CHECK

static uint8_t *__dupFileName(const uint8_t *root_path)
{
    uint8_t *file_name;
    MEM_CHECK(file_name = (uint8_t *)SAFE_MALLOC(strlen((char *)root_path) + 1, LOC_RAW_0001));
    sprintf((char *)file_name, "%s", (char *)root_path);
    return (file_name);
}
开发者ID:petercloud,项目名称:RFS,代码行数:7,代码来源:raw_data.c

示例14: rawFileInit

uint8_t   rawFileInit(RawFile *raw_file, const uint8_t *file_name, const int fd, const int flags, const uint32_t file_size, const word_t cdfs_md_id)
{
    RawData *raw_data;
    MEM_CHECK(raw_file);
    raw_data = rawDataNew(file_size, RAW_FILE_HEAD_SIZE);
    if(NULL == raw_data)
    {
        dbg_log(SEC_0132_RAW, 0)(LOGSTDOUT,"error:rawFileInit: new raw data failed\n");
        return RAW_FILE_FAIL;
    }
    raw_file->fd = fd;
    raw_file->open_flags = flags;
    raw_file->cdfs_md_id = cdfs_md_id;

    if(NULL != file_name)
    {
        raw_file->file_name = __dupFileName(file_name);
    }
    else
    {
        raw_file->file_name = NULL;
    }
    raw_file->raw_data  = raw_data;

    return RAW_FILE_SUCC;
}
开发者ID:petercloud,项目名称:RFS,代码行数:26,代码来源:raw_data.c

示例15: rawFileUpdate8s

uint8_t   rawFileUpdate8s(RawFile *raw_file, const uint8_t *data, const uint32_t len, const uint32_t offset)
{
    MEM_CHECK(raw_file);
    //MEM_CHECK(offset);

    return rawDataUpdate8s(raw_file->raw_data, offset, data, len);
}
开发者ID:petercloud,项目名称:RFS,代码行数:7,代码来源:raw_data.c


注:本文中的MEM_CHECK函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。