您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ HDmalloc函数代码示例

51自学网 2021-06-01 21:22:49
  C++
这篇教程C++ HDmalloc函数代码示例写得很实用,希望能帮到您。

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

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

示例1: getCurrRig

intgetCurrRig(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,


示例2: split_box

PRIVATE     VOIDsplit_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,


示例3: get_unique_name

static voidget_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,


示例4: test_encode_decode

static inttest_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,


示例5: nh5sselect_hyperslab_c

int_fnh5sselect_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,


示例6: h5dread_vl_string_c

int_fh5dread_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,


示例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 voidinit_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,


示例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 inttrav_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,


示例9: test_plists

static inttest_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,


示例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,


示例11: DFgetcomp

intDFgetcomp(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,


示例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_fnh5aget_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,


示例13: encode_plist

static intencode_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,


示例14: UNUSED

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Oget_comment * Signature: (J)Ljava/lang/String; */JNIEXPORT jstring JNICALLJava_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,


示例15: getElement

int32getElement(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,


示例16: init_global

PRIVATE     VOIDinit_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,


示例17: HDgettagsname

/*NAME   HDgettagsname -- return a text name of a tagUSAGE   char * HDgettagsname(tag)   uint16   tag;          IN: tag of element to findRETURNS   Descriptive text or NULLDESCRIPTION   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,


示例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,


示例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,


示例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_fnh5fget_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,


示例21: h5badArgument

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Iget_name_long * Signature: (JLjava/lang/String;J)J */JNIEXPORT jlong JNICALLJava_hdf_hdf5lib_H5_H5Iget_1name_1long    (JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, jlong buf_size){    char *aName;    jstring str;    hssize_t size = -1;    long bs;    bs = (long)buf_size;    if (bs <= 0) {        h5badArgument(env, "H5Iget_name:  buf_size <= 0");    } /* end if */    else {        aName = (char*)HDmalloc(sizeof(char) * (size_t)bs);        if (aName == NULL) {            h5outOfMemory(env, "H5Iget_name:  malloc failed");        } /* end if */        else {            size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size);            if (size < 0) {                h5libraryError(env);            } /* end if */            else {                str = ENVPTR->NewStringUTF(ENVPAR aName);                ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str);            }            HDfree(aName);        }    }    return (jlong)size;} /* end Java_hdf_hdf5lib_H5_H5Iget_1name */
开发者ID:Starlink,项目名称:hdf5,代码行数:37,


示例22: ndailist

ndailist(_fcd filename, intf * tag, intf reflist[], _fcd labellist,         intf * listsize, intf * maxlen, intf * startpos, intf * fnlen){    char       *fn;    int         i;    intf        nrefs;    uint16     *tempreflist;    fn = HDf2cstring(filename, (intn) *fnlen);    if (!fn)	return(-1);    /* create reflist with true uint16s to maintain compatibility       ** with machines that allocate more than 16 bits per uint16.     */    tempreflist = (uint16 *) HDmalloc((size_t) (*listsize) * sizeof(uint16));    /* 1 for isfortran */    nrefs = DFANIlablist(fn, (uint16) *tag, tempreflist,                         (uint8 *) _fcdtocp(labellist),                         (int) *listsize, (int) *maxlen, (int) *startpos, 1);    if (nrefs < 0)        return FAIL;    /* move ref numbers into caller's reflist */    for (i = 0; i < *listsize; i++)        reflist[i] = (intf)tempreflist[i];    HDfree((VOIDP) fn);    HDfree((VOIDP) tempreflist);    return (nrefs);}
开发者ID:Higginbottom,项目名称:zeus_python,代码行数:32,


示例23: H5Aget_name

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Aget_name * Signature: (J)Ljava/lang/String; */JNIEXPORT jstring JNICALLJava_hdf_hdf5lib_H5_H5Aget_1name    (JNIEnv *env, jclass clss, jlong attr_id){    char    *aName;    jstring  str = NULL;    ssize_t  buf_size;    /* get the length of the name */    buf_size = H5Aget_name((hid_t)attr_id, 0, NULL);    if (buf_size <= 0) {        h5badArgument(env, "H5Aget_name:  buf_size <= 0");    } /* end if */    else {        buf_size++; /* add extra space for the null terminator */        aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size);        if (aName == NULL) {            h5outOfMemory(env, "H5Aget_name:  malloc failed");        } /* end if */        else {            buf_size = H5Aget_name((hid_t)attr_id, (size_t)buf_size, aName);            if (buf_size < 0) {                HDfree(aName);                h5libraryError(env);            } /* end if */            else {                /* save the string; */                str = ENVPTR->NewStringUTF(ENVPAR aName);                HDfree(aName);            } /* end else */        } /* end else */    } /* end else */    return str;} /* end Java_hdf_hdf5lib_H5_H5Aget_1name */
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:39,


示例24: nh5fget_name_c

/****if* H5Ff/h5fget_name_c * NAME *        h5fget_name_c * PURPOSE *     Call H5Fget_name to get file's name * INPUTS *      obj_id - object identifier *              buflen -size of the buffer * OUTPUTS *     buf - buffer to hold the name *              size - size of the file's name * RETURNS *     0 on success, -1 on failure * AUTHOR *  Elena Pourmal *              Tuesday, July 6, 2004 * SOURCE*/int_fnh5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen)/******/{    char *c_buf = NULL;           /* Buffer to hold C string */    ssize_t size_c = -1;    int_f ret_value = 0;          /* Return value */     /*      * Allocate buffer to hold name of an attribute      */     if(NULL == (c_buf = (char *)HDmalloc((size_t)*buflen + 1)))         HGOTO_DONE(FAIL);     /*      * Call H5Fget_name function      */     if ((size_c = H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen)) < 0)         HGOTO_DONE(FAIL);     /*      * Convert C name to FORTRAN and place it in the given buffer      */      HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buflen);done:      *size = (size_t_f)size_c;      if(c_buf) HDfree(c_buf);      return ret_value;}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:48,


示例25: nh5_fixname_c

/*---------------------------------------------------------------------------- * Name:        h5_fixname_c * Purpose:     Call h5_fixname to modify file name * Inputs:      base_name - name of the file *              base_namelen - name length *              fapl - file access property list *              full_name - buffer to return full name *              full_namelen - name length * Returns:     0 on success, -1 on failure * Programmer:  Elena Pourmal *              Friday, September 13, 2002 * Modifications: *---------------------------------------------------------------------------*/int_fnh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl, _fcd full_name, size_t_f *full_namelen){     int ret_value = -1;     char *c_base_name;     char *c_full_name;     hid_t c_fapl;     /*      * Define ifile access property list      */     c_fapl = (hid_t)*fapl;     /*      * Convert FORTRAN name to C name      */     c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen);     if (c_base_name == NULL) goto DONE;     c_full_name = (char *) HDmalloc((size_t)*full_namelen + 1);     if (c_full_name == NULL) goto DONE;     /*      * Call h5_fixname function.      */     if (NULL != h5_fixname(c_base_name, c_fapl, c_full_name, (size_t)*full_namelen + 1)) {         HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen);         ret_value = 0;         goto DONE;     }DONE:     if (NULL != c_base_name) HDfree(c_base_name);     if (NULL != c_full_name) HDfree(c_full_name);     return ret_value;}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:47,


示例26: h5iget_name_c

/****if* H5If/h5iget_name_c * NAME *  h5iget_name_c * PURPOSE *  Call H5Iget_name to get object's name * INPUTS *  obj_id - object identifier *  buf_size - size of the buffer * OUTPUTS *  buf - buffer to hold the name * RETURNS *  length of the name on success, -1 on failure * AUTHOR *  Elena Pourmal *  Wednesday, March 12, 2003 * HISTORY * *  Changed the size of c_buf_size to c_buf_size + 1, which *  fixes the problem of truncating the string by 1 if the *  exact size of the string (buf_size) is passed in. *               M. Scot Breitenfeld, April 21, 2008 * SOURCE*/int_fh5iget_name_c(hid_t_f *obj_id, _fcd buf, size_t_f *buf_size, size_t_f *name_size)/******/{     int ret_value = -1;     hid_t c_obj_id;     ssize_t c_size;     size_t c_buf_size;     char *c_buf =NULL;     /*      * Allocate buffer to hold name of an object      */     c_buf_size = (size_t)*buf_size +1;     c_buf = (char *)HDmalloc(c_buf_size);     if (c_buf == NULL) return ret_value;     /*      * Call H5IAget_name function      */     c_obj_id = (hid_t)*obj_id;     c_size = H5Iget_name(c_obj_id, c_buf, c_buf_size);     if (c_size < 0) goto DONE;     /*      * Convert C name to FORTRAN and place it in the given buffer      */      HD5packFstring(c_buf, _fcdtocp(buf), c_buf_size-1);      *name_size = (size_t_f)c_size;      ret_value = 0;DONE:      HDfree(c_buf);      return ret_value;}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:58,


示例27: HCIcszip_encode

/*-------------------------------------------------------------------------- NAME    HCIcszip_encode -- Encode data from a buffer into SZIP compressed data USAGE    int32 HCIcszip_encode(info,length,buf)    compinfo_t *info;   IN: the info about the compressed element    int32 length;       IN: number of bytes to store from the buffer    const uint8 *buf;         OUT: buffer to get the bytes from RETURNS    Returns SUCCEED or FAIL DESCRIPTION    Common code called to encode SZIP data into a file. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG--------------------------------------------------------------------------*/PRIVATE int32HCIcszip_encode(compinfo_t * info, int32 length, const uint8 *buf){    CONSTR(FUNC, "HCIcszip_encode");#ifdef H4_HAVE_SZIP_ENCODER    int bytes_per_pixel;    comp_coder_szip_info_t *szip_info;    /* ptr to SZIP info */    int32 buffer_size;    if (SZ_encoder_enabled() == 0)         HRETURN_ERROR(DFE_NOENCODER, FAIL);    szip_info = &(info->cinfo.coder_info.szip_info);    if (szip_info->szip_state == SZIP_INIT) {	/* Need to initialize */	bytes_per_pixel = (szip_info->bits_per_pixel + 7) >> 3;	if (bytes_per_pixel == 3)		bytes_per_pixel = 4;	buffer_size = szip_info->pixels * bytes_per_pixel;	if ((szip_info->buffer = HDmalloc(buffer_size)) == NULL)			HRETURN_ERROR(DFE_NOSPACE, FAIL);		szip_info->buffer_size = buffer_size;	szip_info->buffer_pos = 0;	szip_info->szip_state = SZIP_RUN;    }
开发者ID:Higginbottom,项目名称:zeus_python,代码行数:48,


示例28: H5PLget

/* * Class:     hdf_hdf5lib_H5 * Method:    H5PLget * Signature: (I)Ljava/lang/String; */JNIEXPORT jstring JNICALLJava_hdf_hdf5lib_H5_H5PLget  (JNIEnv *env, jclass clss, jint index){    char *aName;    jstring  str = NULL;    ssize_t  buf_size;    /* get the length of the name */    buf_size = H5PLget(index, NULL, 0);    if (buf_size <= 0) {        h5badArgument(env, "H5PLget:  buf_size <= 0");    } /* end if */    else {        buf_size++; /* add extra space for the null terminator */        aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size);        if (aName == NULL) {            h5outOfMemory(env, "H5PLget:  malloc failed");        } /* end if */        else {            buf_size = H5PLget(index, aName, (size_t)buf_size);            if (buf_size < 0) {                h5libraryError(env);            } /* end if */            else {                str = ENVPTR->NewStringUTF(ENVPAR aName);            }            HDfree(aName);        }    }    return str;} /* end Java_hdf_hdf5lib_H5_H5PLget */
开发者ID:Starlink,项目名称:hdf5,代码行数:38,


示例29: test_long_desc

/*------------------------------------------------------------------------- * Function:	test_long_desc * * Purpose:	Test long error description handling * * Return:	Success:	0 * *		Failure:	-1 * * Programmer:	Quincey Koziol *		January 19, 2005 * *------------------------------------------------------------------------- */static herr_ttest_long_desc(void){    const char          *format = "Testing very long description string, %s";    char                *long_desc = NULL;    char                *full_desc = NULL;    size_t              u;    const char          *test_FUNC = "test_long_desc";    /* Allocate space for the error description info */    if(NULL == (long_desc = (char*)HDmalloc(LONG_DESC_SIZE))) TEST_ERROR;    if(NULL == (full_desc = (char*)HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR;    /* Create the long part of the error description */    for(u = 0; u < LONG_DESC_SIZE; u++)        long_desc[u] = 'A' + (u % 26);    long_desc[LONG_DESC_SIZE - 1] = '/0';    /* Clear the default error stack */    if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR;    /* Push an error with a long description */    if(H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) TEST_ERROR;    /* Create the string that should be in the description. Must use HDsnprintf here     * because snprintf is _snprintf on Windows */    HDsnprintf(full_desc, (size_t)(LONG_DESC_SIZE + 128), format, long_desc);    /* Make certain that the description is correct */    if(H5Ewalk2(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc) < 0) TEST_ERROR;    /* Clear the default error stack again */    if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR;    HDfree(long_desc);    HDfree(full_desc);    return(0);error:    if(long_desc)        HDfree(long_desc);    if(full_desc)        HDfree(full_desc);    return(-1);} /* end test_long_desc() */
开发者ID:adasworks,项目名称:hdf5,代码行数:61,


示例30: h5badArgument

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Eget_msg * Signature: (J[I)Ljava/lang/String; */JNIEXPORT jstring JNICALLJava_hdf_hdf5lib_H5_H5Eget_1msg    (JNIEnv *env, jclass cls, jlong msg_id, jintArray error_msg_type_list){    char      *namePtr;    jstring    str = NULL;    jboolean   isCopy;    ssize_t    buf_size;    jint      *theArray;    H5E_type_t error_msg_type;    if (msg_id < 0) {        h5badArgument(env, "H5Eget_msg: invalid argument");    } /* end if */    else if (error_msg_type_list == NULL) {        h5nullArgument(env, "H5Eget_msg:  error_msg_type_list is NULL");    } /* end if */    else {        /* get the length of the name */        buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0);        if ((buf_size < 0) || (buf_size == 0)) {            h5JNIFatalError(env, "H5Eget_msg:  Invalid message");        } /* end if */        else {            buf_size++; /* add extra space for the null terminator */            namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size);            if (namePtr == NULL) {                h5outOfMemory(env, "H5Eget_msg:  malloc failed");            } /* end if */            else {                theArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR error_msg_type_list, &isCopy);                if (theArray == NULL) {                    HDfree(namePtr);                    h5JNIFatalError(env, "H5Eget_msg:  error_msg_type_list not pinned");                } /* end if */                else {                    buf_size = H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size);                    if (buf_size < 0) {                        HDfree(namePtr);                        ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, JNI_ABORT);                        h5libraryError(env);                    } /* end if */                    else {                        theArray[0] = error_msg_type;                        ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, 0);                        str = ENVPTR->NewStringUTF(ENVPAR namePtr);                        HDfree(namePtr);                    } /* end else */                } /* end else */            } /* end else */        } /* end else */    } /* end else */    return str;} /* end Java_hdf_hdf5lib_H5_H5Eget_1msg */
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:63,



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


C++ HDstrcmp函数代码示例
C++ HDfree函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。