/src/gdal/netcdf-c-4.7.4/libhdf5/nc4mem.c
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************* |
2 | | * Copyright 2018, UCAR/Unidata |
3 | | * See netcdf/COPYRIGHT file for copying and redistribution conditions. |
4 | | * ********************************************************************/ |
5 | | |
6 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7 | | * Copyright by The HDF Group. * |
8 | | * Copyright by the Board of Trustees of the University of Illinois. * |
9 | | * All rights reserved. * |
10 | | * * |
11 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
12 | | * terms governing use, modification, and redistribution, is contained in * |
13 | | * the COPYING file, which can be found at the root of the source code * |
14 | | * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * |
15 | | * If you do not have access to either file, you may request a copy from * |
16 | | * help@hdfgroup.org. * |
17 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
18 | | |
19 | | #include "config.h" |
20 | | #include "hdf5internal.h" |
21 | | #include <H5DSpublic.h> /* must be after nc4internal.h */ |
22 | | #include <H5Fpublic.h> |
23 | | #include <H5LTpublic.h> |
24 | | |
25 | | #include "netcdf.h" |
26 | | #include "nc4internal.h" |
27 | | |
28 | | #undef DEBUG |
29 | | |
30 | | #ifndef HDrealloc |
31 | | #define HDrealloc(M,Z) realloc(M,Z) |
32 | | #endif /* HDrealloc */ |
33 | | |
34 | | int |
35 | | NC4_open_image_file(NC_FILE_INFO_T* h5) |
36 | 0 | { |
37 | 0 | int stat = NC_NOERR; |
38 | 0 | hid_t hdfid; |
39 | | |
40 | | /* check arguments */ |
41 | 0 | if(h5->mem.memio.memory == NULL || h5->mem.memio.size == 0) |
42 | 0 | {stat = NC_EINVAL; goto done;} |
43 | | |
44 | | /* Figure out the image flags */ |
45 | 0 | h5->mem.imageflags = 0; |
46 | 0 | if(h5->mem.locked) { |
47 | 0 | h5->mem.imageflags |= (H5LT_FILE_IMAGE_DONT_COPY | H5LT_FILE_IMAGE_DONT_RELEASE); |
48 | 0 | } |
49 | 0 | if(!h5->no_write) |
50 | 0 | h5->mem.imageflags |= H5LT_FILE_IMAGE_OPEN_RW; |
51 | | |
52 | | /* Create the file but using our version of H5LTopen_file_image */ |
53 | 0 | hdfid = NC4_image_init(h5); |
54 | 0 | if(hdfid < 0) |
55 | 0 | {stat = NC_EHDFERR; goto done;} |
56 | | |
57 | | /* Remember HDF5 file identifier. */ |
58 | 0 | ((NC_HDF5_FILE_INFO_T *)h5->format_file_info)->hdfid = hdfid; |
59 | |
|
60 | 0 | done: |
61 | 0 | return stat; |
62 | 0 | } |
63 | | |
64 | | int |
65 | | NC4_create_image_file(NC_FILE_INFO_T* h5, size_t initialsz) |
66 | 0 | { |
67 | 0 | int stat = NC_NOERR; |
68 | 0 | hid_t hdfid; |
69 | | |
70 | | /* Create the file but using our version of H5LTopen_file_image */ |
71 | 0 | h5->mem.created = 1; |
72 | 0 | h5->mem.initialsize = initialsz; |
73 | 0 | h5->mem.imageflags |= H5LT_FILE_IMAGE_OPEN_RW; |
74 | 0 | hdfid = NC4_image_init(h5); |
75 | 0 | if(hdfid < 0) |
76 | 0 | {stat = NC_EHDFERR; goto done;} |
77 | | /* Remember HDF5 file identifier. */ |
78 | 0 | ((NC_HDF5_FILE_INFO_T *)h5->format_file_info)->hdfid = hdfid; |
79 | 0 | done: |
80 | 0 | return stat; |
81 | 0 | } |