• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HDmalloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCurrRig

int
getCurrRig(int32 *pXdim, int32 *pYdim, char **pPalette, char **pRaster)
{
    int         ispal;

    goTo(he_currDesc);

    if (DFR8getdims(he_file, pXdim, pYdim, &ispal) < 0)
      {
          fprintf(stderr, "Error getting image group.\n");
          HEprint(stderr, 0);
          return FAIL;
      }
    if (ispal)
        *pPalette = (char *) HDmalloc(HE_PALETTE_SZ);
    else
        *pPalette = (char *) NULL;
    *pRaster = (char *) HDmalloc((size_t)(*pXdim) * (size_t)(*pYdim));

    if (DFR8getimage(he_file, (unsigned char *) *pRaster, *pXdim, *pYdim,
                     (unsigned char *) *pPalette) == FAIL)
      {
          fprintf(stderr, "Error getting image group.\n");
          HEprint(stderr, 0);
          return FAIL;
      }

    return HE_OK;
}
开发者ID:schwehr,项目名称:hdf4,代码行数:29,代码来源:he_main.c


示例2: split_box

PRIVATE     VOID
split_box(struct box * ptr)
{
    int         dim, j, i;
    float       median;
    struct box *l_child, *r_child;

    dim = select_dim(ptr);
    median = find_med(ptr, dim);

    /* create 2 child */
    l_child = (struct box *) HDmalloc(sizeof(struct box));
    r_child = (struct box *) HDmalloc(sizeof(struct box));

    for (i = RED; i <= BLUE; i++)
        for (j = HI; j <= LO; j++)
          {
              l_child->bnd[i][j] = ptr->bnd[i][j];
              r_child->bnd[i][j] = ptr->bnd[i][j];
          }
    l_child->bnd[dim][HI] = median;
    r_child->bnd[dim][LO] = median;

    classify(ptr, l_child);
    classify(ptr, r_child);

    r_child->right = ptr->right;
    r_child->left = l_child;
    l_child->right = r_child;
    l_child->left = ptr->left;
    (ptr->left)->right = l_child;
    if (ptr->right != NULL)
        (ptr->right)->left = r_child;
}   /* end of split_box */
开发者ID:schwehr,项目名称:hdf4,代码行数:34,代码来源:dfimcomp.c


示例3: get_unique_name

static void
get_unique_name(void)
{
    const char *prefix = NULL;
    const char *env = HDgetenv("HDF5_PREFIX");

    if (env)
        prefix = env;

    if (option_prefix)
        prefix = option_prefix;

    if (prefix)
        /* 2 = 1 for '/' + 1 for null terminator */
        filename = (char *) HDmalloc(HDstrlen(prefix) + HDstrlen(ZIP_PERF_FILE) + 2);
    else
        filename = (char *) HDmalloc(HDstrlen(ZIP_PERF_FILE) + 1);

    if (!filename)
        error("out of memory");

    filename[0] = 0;
    if (prefix){
        HDstrcpy(filename, prefix);
        HDstrcat(filename, "/");
    }
    HDstrcat(filename, ZIP_PERF_FILE);
}
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:28,代码来源:zip_perf.c


示例4: test_encode_decode

static int
test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc)
{
    MPI_Request req[2];
    MPI_Status status;
    hid_t pl;                   /* Decoded property list */
    size_t buf_size = 0;
    void *sbuf = NULL;
    herr_t ret;         	/* Generic return value */

    if(mpi_rank == 0) {
        int send_size = 0;

        /* first call to encode returns only the size of the buffer needed */
        ret = H5Pencode(orig_pl, NULL, &buf_size);
        VRFY((ret >= 0), "H5Pencode succeeded");

        sbuf = (uint8_t *)HDmalloc(buf_size);

        ret = H5Pencode(orig_pl, sbuf, &buf_size);
        VRFY((ret >= 0), "H5Pencode succeeded");

        /* this is a temp fix to send this size_t */
        send_size = (int)buf_size;

        MPI_Isend(&send_size, 1, MPI_INT, recv_proc, 123, MPI_COMM_WORLD, &req[0]);
        MPI_Isend(sbuf, send_size, MPI_BYTE, recv_proc, 124, MPI_COMM_WORLD, &req[1]);
    } /* end if */

    if(mpi_rank == recv_proc) {
        int recv_size;
        void *rbuf;

        MPI_Recv(&recv_size, 1, MPI_INT, 0, 123, MPI_COMM_WORLD, &status);
        buf_size = recv_size;
        rbuf = (uint8_t *)HDmalloc(buf_size);
        MPI_Recv(rbuf, recv_size, MPI_BYTE, 0, 124, MPI_COMM_WORLD, &status);

        pl = H5Pdecode(rbuf);
        VRFY((pl >= 0), "H5Pdecode succeeded");

        VRFY(H5Pequal(orig_pl, pl), "Property List Equal Succeeded");

        ret = H5Pclose(pl);
        VRFY((ret >= 0), "H5Pclose succeeded");

        if(NULL != rbuf)
            HDfree(rbuf);
    } /* end if */

    if(0 == mpi_rank)
        MPI_Waitall(2, req, MPI_STATUSES_IGNORE);

    if(NULL != sbuf)
        HDfree(sbuf);

    MPI_Barrier(MPI_COMM_WORLD);
    return(0);
}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:59,代码来源:t_prop.c


示例5: nh5sselect_hyperslab_c

int_f
nh5sselect_hyperslab_c ( hid_t_f *space_id , int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block)
{
  int ret_value = -1;
  hid_t c_space_id;
  hsize_t *c_start = NULL;
  hsize_t *c_count = NULL;
  hsize_t *c_stride = NULL;
  hsize_t *c_block = NULL;

  H5S_seloper_t c_op;
  herr_t  status;
  int rank;
  int i;

  rank = H5Sget_simple_extent_ndims(*space_id);
  if (rank < 0 ) return ret_value;
  c_start = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
  if (c_start == NULL) goto DONE;

  c_count = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
  if (c_count == NULL) goto DONE;

  c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
  if (c_stride == NULL) goto DONE;

  c_block = (hsize_t *)HDmalloc(sizeof(hsize_t)*rank);
  if (c_block == NULL) goto DONE;


  /*
   * Reverse dimensions due to C-FORTRAN storage order.
   */

  for (i=0; i < rank; i++) {
      int t= (rank - i) - 1;
      c_start[i] = (hsize_t)start[t];
      c_count[i] = (hsize_t)count[t];
      c_stride[i] = (hsize_t)stride[t];
      c_block[i] = (hsize_t)block[t];
  }

   c_op = (H5S_seloper_t)*op;
/*
  if (*op == H5S_SELECT_SET_F) c_op = H5S_SELECT_SET;
  if (*op == H5S_SELECT_OR_F)  c_op = H5S_SELECT_OR;
*/

  c_space_id = *space_id;
  status = H5Sselect_hyperslab(c_space_id, c_op, c_start, c_stride, c_count, c_block);
  if ( status >= 0  ) ret_value = 0;
DONE:
  if(c_start != NULL) HDfree(c_start);
  if(c_count != NULL) HDfree(c_count);
  if(c_stride!= NULL) HDfree(c_stride);
  if(c_block != NULL) HDfree(c_block);
  return ret_value;
}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:58,代码来源:H5Sf.c


示例6: h5dread_vl_string_c

int_f
h5dread_vl_string_c( hid_t_f *dset_id ,  hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len)
/******/
{
  int ret_value = -1;
  hid_t c_dset_id;
  hid_t c_mem_type_id;
  hid_t c_mem_space_id;
  hid_t c_file_space_id;
  hid_t c_xfer_prp;
  herr_t status;
  char *tmp, *tmp_p;
  size_t max_len;

  char **c_buf;
  hsize_t i;
  hsize_t num_elem;

  max_len = (size_t)dims[0];
  num_elem = (hsize_t)dims[1];

  c_dset_id       = (hid_t)*dset_id;
  c_mem_type_id   = (hid_t)*mem_type_id;
  c_mem_space_id  = (hid_t)*mem_space_id;
  c_file_space_id = (hid_t)*file_space_id;
  c_xfer_prp      = (hid_t)*xfer_prp;

  /*
   * Allocate array of character pointers
   */
  c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *));
  if (c_buf == NULL) return ret_value;

  /*
   * Call H5Dread function.
   */
   status = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf);
   if (status < 0) { HDfree(c_buf);
                     return ret_value;
                   }
  /* Copy data to long C string */
  tmp = (char *)HDmalloc((size_t)(max_len*num_elem) +1);
  tmp_p = tmp;
  for (i=0; i<max_len*num_elem; i++) tmp[i] = ' ';
  tmp[max_len*num_elem] = '\0';
  for (i=0; i < num_elem; i++) {
        memcpy(tmp_p, c_buf[i], strlen(c_buf[i]));
        len[i] = (size_t_f)strlen(c_buf[i]);
        tmp_p = tmp_p + max_len;
  }
  HD5packFstring(tmp, _fcdtocp(buf), (size_t)(max_len*num_elem));
  ret_value = 0;
  H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
  HDfree(c_buf);
  HDfree(tmp);
  return ret_value;
}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:57,代码来源:H5Df.c


示例7: init_table

/*-------------------------------------------------------------------------
 * Function:    init_table
 *
 * Purpose:     allocate and initialize tables for shared groups, datasets,
 *              and committed types
 *
 * Return:      void
 *
 * Programmer:  Ruey-Hsia Li
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static void
init_table(table_t **tbl)
{
    table_t *table = (table_t *)HDmalloc(sizeof(table_t));

    table->size = 20;
    table->nobjs = 0;
    table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));

    *tbl = table;
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:25,代码来源:h5tools_utils.c


示例8: trav_print_visit_lnk

/*-------------------------------------------------------------------------
 * Function: trav_print_visit_lnk
 *
 * Purpose:  Callback for visiting link, when printing info
 *
 * Return:   0 on success,
 *          -1 on failure
 *-------------------------------------------------------------------------
 */
static int
trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
{
    trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;

    /* Print appropriate information for the type of link */
    switch(linfo->type) {
        case H5L_TYPE_SOFT:
            if(linfo->u.val_size > 0) {
                char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
                if(targbuf) {
                    if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
                        targbuf[0] = 0;
                    printf(" %-10s %s -> %s\n", "link", path, targbuf);
                    HDfree(targbuf);
                }
            } /* end if */
            else
                printf(" %-10s %s ->\n", "link", path);
            break;

        case H5L_TYPE_EXTERNAL:
            if(linfo->u.val_size > 0) {
                char *targbuf = NULL;
                const char *filename = NULL;
                const char *objname = NULL;

                targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
                if(targbuf) {
                    if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
                        targbuf[0] = 0;
                    if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0)
                        printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
                    HDfree(targbuf);
                }
            } /* end if */
            else
                printf(" %-10s %s ->\n", "ext link", path);
            break;

        case H5L_TYPE_HARD:
            /* Should be handled elsewhere */
            return(-1);

        case H5L_TYPE_ERROR:
        case H5L_TYPE_MAX:
        default:
            printf(" %-10s %s -> ???\n", "unknown type of UD link", path);
            break;
    } /* end switch() */

    return(0);
} /* end trav_print_visit_lnk() */
开发者ID:GATB,项目名称:gatb-core,代码行数:62,代码来源:h5trav.c


示例9: test_plists

static int
test_plists(const char *filename1, const char *filename2) 
{
    int fd_le, fd_be;
    size_t size_le = 0, size_be = 0;
    void *buf_le = NULL, *buf_be = NULL;
    hid_t plist_le, plist_be;	       	/* dataset create prop. list */
    const char *testfile;

    testfile = H5_get_srcdir_filename(filename1);
    if((fd_le = HDopen(testfile, O_RDONLY, 0666)) < 0)
        TEST_ERROR
    size_le = HDlseek(fd_le, (HDoff_t)0, SEEK_END);
    HDlseek(fd_le, (HDoff_t)0, SEEK_SET);
    buf_le = (void *)HDmalloc(size_le);
    if(HDread(fd_le, buf_le, size_le) < 0)
        TEST_ERROR
    HDclose(fd_le);

    testfile = H5_get_srcdir_filename(filename2);
    if((fd_be = HDopen(testfile, O_RDONLY, 0666)) < 0)
        TEST_ERROR
    size_be = HDlseek(fd_be, (HDoff_t)0, SEEK_END);
    HDlseek(fd_be, (HDoff_t)0, SEEK_SET);
    buf_be = (void *)HDmalloc(size_be);
    if(HDread(fd_be, buf_be, size_be) < 0)
        TEST_ERROR
    HDclose(fd_be);

    if((plist_le = H5Pdecode(buf_le)) < 0)
        FAIL_STACK_ERROR
    if((plist_be = H5Pdecode(buf_be)) < 0)
        FAIL_STACK_ERROR

    if(!H5Pequal(plist_le, plist_be))
        FAIL_PUTS_ERROR("PLIST encoding/decoding comparison failed\n")

    if((H5Pclose(plist_le)) < 0)
        FAIL_STACK_ERROR
    if((H5Pclose(plist_be)) < 0)
        FAIL_STACK_ERROR

    HDfree(buf_le);
    HDfree(buf_be);

    return 1;

error:
    printf("***** Plist Encode/Decode tests FAILED! *****\n");
    return -1;
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:51,代码来源:enc_dec_plist_with_endianess.c


示例10: read_dataset

/*
 * This function opens all the datasets in a certain, checks the data using
 * dataset_vrfy function.
 *
 * Changes:     Updated function to use a dynamically calculated size,
 *              instead of the old SIZE #define.  This should allow it
 *              to function with an arbitrary number of processors.
 *
 *                                              JRM - 8/11/04
 */
int read_dataset(hid_t memspace, hid_t filespace, hid_t gid)
{
    int i, j, n, mpi_rank, mpi_size, size, attr_errors=0, vrfy_errors=0;
    char dname[32];
    DATATYPE *outdata = NULL, *indata = NULL;
    hid_t did;

    MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
    MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);

    size = get_size();

    indata = (DATATYPE*)HDmalloc((size_t)(size * size * sizeof(DATATYPE)));
    VRFY((indata != NULL), "HDmalloc succeeded for indata");

    outdata = (DATATYPE*)HDmalloc((size_t)(size * size * sizeof(DATATYPE)));
    VRFY((outdata != NULL), "HDmalloc succeeded for outdata");

    for(n=0; n<NDATASET; n++) {
        sprintf(dname, "dataset%d", n);
        did = H5Dopen(gid, dname);
        VRFY((did>0), dname);

        H5Dread(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT,
                indata);

        /* this is the original value */
        for(i=0; i<size; i++)
	    for(j=0; j<size; j++) {
	         *outdata = n*1000 + mpi_rank;
                 outdata++;
	    }
        outdata -= size * size;

        /* compare the original value(outdata) to the value in file(indata).*/
        vrfy_errors = check_value(indata, outdata, size);

        /* check attribute.*/
        if( (attr_errors = read_attribute(did, is_dset, n))>0 )
            vrfy_errors += attr_errors;

        H5Dclose(did);
    }

    HDfree(indata);
    HDfree(outdata);

    return vrfy_errors;
}
开发者ID:einon,项目名称:affymetrix-power-tools,代码行数:59,代码来源:t_mdset.c


示例11: DFgetcomp

int
DFgetcomp(int32 file_id, uint16 tag, uint16 ref, uint8 *image, int32 xdim,
          int32 ydim, uint16 scheme)
{
    CONSTR(FUNC, "DFgetcomp");
    uint8      *buffer;
    uint8      *in;
    uint8      *out;
    int32       cisize, crowsize, buflen, bufleft;  /* bufleft: bytes left in buffer */

    int32       i;
    int32       totalread;
    int32       n;
    int32       aid;

    if (!HDvalidfid(file_id) || !tag || !ref || xdim <= 0 || ydim <= 0 || !image)
        HRETURN_ERROR(DFE_ARGS, FAIL);

    /* put this call up here instead of in switch statement, to make the */
    /* code easier to follow */
    if (scheme == DFTAG_JPEG5 || scheme == DFTAG_GREYJPEG5
            || scheme==DFTAG_JPEG || scheme==DFTAG_GREYJPEG)
        return (DFCIunjpeg(file_id, tag, ref, (VOIDP) image, xdim, ydim, (int16)scheme));

    /* Only do this stuff for non-JPEG compressed images */
    aid = Hstartread(file_id, tag, ref);
    if (aid == FAIL)
        HRETURN_ERROR(DFE_NOMATCH, FAIL);
    if (Hinquire(aid, (int32 *) NULL, (uint16 *) NULL, (uint16 *) NULL, &cisize,
    (int32 *) NULL, (int32 *) NULL, (int16 *) NULL, (int16 *) NULL) == FAIL)
        return FAIL;

    switch (scheme)
      {
          case DFTAG_RLE:
              crowsize = xdim * 121 / 120 + 128;    /* max size of a row */

              buffer = (uint8 *) HDmalloc((uint32) cisize);
              if (!buffer)
                {
                    buffer = (uint8 *) HDmalloc((uint32) crowsize);
                    if (!buffer)
                      {
                          Hendaccess(aid);
                          HRETURN_ERROR(DFE_NOSPACE, FAIL)
                      }     /* end if */
                    buflen = crowsize;
                }   /* end if */
开发者ID:Higginbottom,项目名称:zeus_python,代码行数:48,代码来源:dfcomp.c


示例12: nh5aget_name_c

/*----------------------------------------------------------------------------
 * Name:        h5aget_name_c
 * Purpose:     Call H5Aget_name to get attribute's name
 * Inputs:      attr_id - attribute identifier
 *              bufsize -size of the buffer
 * Outputs:     buf - buffer to hold the name
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Thursday, August 12, 1999
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf)
{
    char *c_buf=NULL;           /* Buffer to hold C string */
    int_f ret_value=0;          /* Return value */

     /*
      * Allocate buffer to hold name of an attribute
      */
     if ((c_buf = HDmalloc((size_t)*bufsize +1)) == NULL)
         HGOTO_DONE(FAIL);

     /*
      * Call H5Aget_name function
      */
     if ((ret_value = (int_f)H5Aget_name((hid_t)*attr_id, (size_t)*bufsize, c_buf)) < 0)
         HGOTO_DONE(FAIL);

     /*
      * Convert C name to FORTRAN and place it in the given buffer
      */
      HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*bufsize);

done:
      if(c_buf) HDfree(c_buf);
      return ret_value;
}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:38,代码来源:H5Af.c


示例13: encode_plist

static int
encode_plist(hid_t plist_id, int little_endian, const char *filename_le, const char *filename_be)
{
    int fd = 0; /* file descriptor */
    herr_t ret = 0;
    void *temp_buf = NULL;
    size_t temp_size = 0;
    ssize_t write_size;

    /* first call to encode returns only the size of the buffer needed */
    if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0)
        assert(ret > 0);

    temp_buf = (void *)HDmalloc(temp_size);
    assert(temp_buf);

    if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0)
        assert(ret > 0);

    if(little_endian)
        fd = HDopen(filename_le, O_RDWR | O_CREAT | O_TRUNC, 0666);
    else
        fd = HDopen(filename_be, O_RDWR | O_CREAT | O_TRUNC, 0666);
    assert(fd > 0);

    write_size = HDwrite(fd, temp_buf, temp_size);
    assert(write_size == (ssize_t)temp_size);

    HDclose(fd);
    
    HDfree(temp_buf);

    return 1;
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:34,代码来源:gen_plist.c


示例14: UNUSED

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Oget_comment
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Oget_1comment
    (JNIEnv *env, jclass clss, jlong loc_id)
{
    jstring  str = NULL;
    ssize_t  buf_size;
    ssize_t  status = -1;
    char    *oComment = NULL;

    UNUSED(clss);

    /* Get the length of the comment */
    if ((buf_size = H5Oget_comment((hid_t)loc_id, NULL, 0)) < 0)
        H5_LIBRARY_ERROR(ENVONLY);

    if (buf_size) {
        if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
            H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer");

        if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0)
            H5_LIBRARY_ERROR(ENVONLY);
        oComment[buf_size] = '\0';

        if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, oComment)))
            CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
    }

done:
    if (oComment)
        HDfree(oComment);

    return (jstring)str;
} /* end Java_hdf_hdf5lib_H5_H5Oget_1comment */
开发者ID:soumagne,项目名称:hdf5,代码行数:38,代码来源:h5oImp.c


示例15: getElement

int32
getElement(int desc, char **pdata)
{
    int32       length;
    int32       fid;

    length = he_desc[desc].length;

    /* alloc memory to read the element in */
    *pdata = (char *) HDmalloc(length);
    if (*pdata == NULL)
        return FAIL;

    /* read in the element and check for error */
    if ((fid = Hopen(he_file, DFACC_READ, 0)) == 0)
      {
          HEprint(stderr, 0);
          return FAIL;
      }
    if (Hgetelement(fid, he_desc[desc].tag, he_desc[desc].ref, (unsigned char *) (*pdata)) < 0)
      {
          HDfree(*pdata);
          fprintf(stderr, "Cannot read element.\n");
          return FAIL;
      }
    Hclose(fid);
    return length;
}
开发者ID:schwehr,项目名称:hdf4,代码行数:28,代码来源:he_main.c


示例16: init_global

PRIVATE     VOID
init_global(int32 xdim, int32 ydim, VOIDP out, VOIDP out_pal)
{
    int32       i, j;

    /* allocate memory */
    image = (unsigned char *) out;
    new_pal = (unsigned char *) out_pal;
    if (color_pt)
        HDfree((VOIDP) color_pt);
    color_pt = (struct rgb *) HDmalloc((unsigned) ((xdim * ydim) / 8) *
                                         sizeof(struct rgb));

    if (image == NULL || color_pt == NULL || new_pal == NULL)
      {
          return; /* punt! */
      }

    /* initialize */
    for (i = 0; i < (xdim * ydim / 4); i++)
        image[i] = 0;

    for (i = 0; i < (xdim * ydim / 8); i++)
        for (j = RED; j <= BLUE; j++)
            color_pt[i].c[j] = 0;

    for (i = 0; i < MAXCOLOR; i++)
        trans[i] = -1;
}   /* end of init_global */
开发者ID:schwehr,项目名称:hdf4,代码行数:29,代码来源:dfimcomp.c


示例17: HDgettagsname

/*
NAME
   HDgettagsname -- return a text name of a tag
USAGE
   char * HDgettagsname(tag)
   uint16   tag;          IN: tag of element to find
RETURNS
   Descriptive text or NULL
DESCRIPTION
   Map a tag to a dynamically allocated text name of it.
   Checks for special elements now.

--------------------------------------------------------------------------- */
char *
HDgettagsname(uint16 tag)
{
    CONSTR(FUNC, "HDgettagsname");  /* for HERROR */
    char       *ret = NULL;
    intn        i;

    if (SPECIALTAG(tag))
        ret = (char *) HDstrdup("Special ");
    tag = BASETAG(tag);
    for (i = 0; i < (intn)(sizeof(tag_descriptions) / sizeof(tag_descript_t)); i++)
        if (tag_descriptions[i].tag == tag)
          {
              if (ret == NULL)
                  ret = (char *) HDstrdup(tag_descriptions[i].name);
              else
                {
                    char       *t;

                    t = (char *) HDmalloc(HDstrlen(ret) +
                                    HDstrlen(tag_descriptions[i].name) + 2);
                    if (t == NULL)
                      {
                          HDfree(ret);
                          HRETURN_ERROR(DFE_NOSPACE, NULL)
                      }     /* end if */
                    HDstrcpy(t, ret);
                    HDstrcat(t, tag_descriptions[i].name);
                    HDfree(ret);
                    ret = t;
                }   /* end else */
          }     /* end if */
开发者ID:schwehr,项目名称:hdf4,代码行数:45,代码来源:hkit.c


示例18: list

/******************************************************************************
 NAME
     HULIget_list_node - Gets a list node

 DESCRIPTION
    Either gets an list node from the free list (if there is one available)
    or allocate a node.

 RETURNS
    Returns list node ptr if successful and NULL otherwise

*******************************************************************************/
static node_info_t *HULIget_list_node(void)
{
    CONSTR(FUNC, "HULIget_list_node");	/* for HERROR */
    node_info_t *ret_value=NULL;

    HEclear();
    if(node_free_list!=NULL)
      {
        ret_value=node_free_list;
        node_free_list=node_free_list->next;
      } /* end if */
    else
      {
        if((ret_value=(node_info_t *)HDmalloc(sizeof(node_info_t)))==NULL)
            HGOTO_ERROR(DFE_NOSPACE, NULL);
      } /* end else */

done:
  if(ret_value == NULL)   
    { /* Error condition cleanup */

    } /* end if */

  /* Normal function cleanup */

  return ret_value;
}   /* end HULIget_list_node() */
开发者ID:Higginbottom,项目名称:zeus_python,代码行数:39,代码来源:linklist.c


示例19: list_table_add

void list_table_add(list_table_t *list_tbl, int tag, int ref, char* path)
{
    int path_len;
    int i;
    
    if (list_tbl->nobjs == list_tbl->size) 
    {
        list_tbl->size *= 2;
        list_tbl->objs = (obj_info_t*)realloc(list_tbl->objs, list_tbl->size * sizeof(obj_info_t));
        
        for (i = list_tbl->nobjs; i < list_tbl->size; i++) 
        {
            list_tbl->objs[i].tag = -1;
            list_tbl->objs[i].ref = -1;
            list_tbl->objs[i].path = NULL;
        }
    }
    
    i = list_tbl->nobjs++;
    list_tbl->objs[i].tag = tag;
    list_tbl->objs[i].ref = ref;

    /* copy the path over */
    path_len = HDstrlen(path);
    list_tbl->objs[i].path = (char *)HDmalloc(path_len+1);
    HIstrncpy(list_tbl->objs[i].path, path, path_len+1);
}
开发者ID:schwehr,项目名称:hdf4,代码行数:27,代码来源:hrepack_lsttable.c


示例20: nh5fget_obj_ids_c

/****if* H5Ff/h5fget_obj_ids_c
 * NAME
 *  h5fget_obj_ids_c
 * PURPOSE
 *  Call H5Fget_obj_count to get number of open objects within a file
 * INPUTS
 *  file_id  - identifier of the file to be closed
 *  obj_type - type of the object
 * RETURNS
 *  obj_ids  - iarray of open objects identifiers
 *              0 on success, -1 on failure
 * AUTHOR
 *  Elena Pourmal
 *  Monday, September 30, 2002
 * HISTORY
 *
 *  Changed type of max_obj to size_t_f; added parameter for the
 *  number of open objects
 *  Thursday, September 25, 2008 EIP
 *	
 * SOURCE
*/
int_f
nh5fget_obj_ids_c ( hid_t_f *file_id , int_f *obj_type, size_t_f *max_objs, 
    hid_t_f *obj_ids, size_t_f *num_objs)
/******/
{
    int ret_value = 0;
    hid_t c_file_id;
    unsigned c_obj_type;
    size_t u;
    size_t c_max_objs;
    ssize_t c_num_objs;
    hid_t *c_obj_ids;

    c_file_id = (hid_t)*file_id;
    c_obj_type = (unsigned) *obj_type;
    c_max_objs = (size_t)*max_objs;
    c_obj_ids = (hid_t *)HDmalloc(sizeof(hid_t)*c_max_objs);

    c_num_objs = H5Fget_obj_ids(c_file_id, c_obj_type, c_max_objs, c_obj_ids);
    if(c_num_objs < 0)
        ret_value = -1;
    for(u = 0; u < c_max_objs; u++)
        obj_ids[u] = (hid_t_f)c_obj_ids[u];

    HDfree(c_obj_ids);
    *num_objs = (size_t_f)c_num_objs;

    return ret_value;
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:51,代码来源:H5Ff.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HDstrcmp函数代码示例发布时间:2022-05-30
下一篇:
C++ HDfree函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap