[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 653e5c0: gal_data_alloc defined before gal_dat
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 653e5c0: gal_data_alloc defined before gal_data_initialize in code and book |
Date: |
Thu, 31 May 2018 17:05:30 -0400 (EDT) |
branch: master
commit 653e5c038a763d3fafc2eb0ad3dc72ec694d60ab
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
gal_data_alloc defined before gal_data_initialize in code and book
`gal_data_alloc' is a higher-level function and more commonly used compared
to `gal_data_initialize'. To get to it in the manual however, first we have
to skim over `gal_data_initialize' (which is long). With this commit, we
are brigning the definition of `gal_data_alloc' (in the code and book,
which should have the same order) before `gal_data_initialize'.
---
doc/gnuastro.texi | 24 +++++++++++-----------
lib/data.c | 58 ++++++++++++++++++++++++++---------------------------
lib/gnuastro/data.h | 10 ++++-----
3 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index c1d7fd7..704602f 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -22433,6 +22433,17 @@ The functions listed in this section describe the most
basic operations on
are declared in @file{gnuastro/data.h} which is also visible from the
function names (see @ref{Gnuastro library}).
address@hidden {gal_data_t *} gal_data_alloc (void @code{*array}, uint8_t
@code{type}, size_t @code{ndim}, size_t @code{*dsize}, struct wcsprm
@code{*wcs}, int @code{clear}, size_t @code{minmapsize}, char @code{*name},
char @code{*unit}, char @code{*comment})
+
+Dynamically allocate a @code{gal_data_t} and initialize it will all the
+given values. See the description of @code{gal_data_initialize} and
address@hidden data container} for more information. This function will often
+be the most frequently used because it allocates the @code{gal_data_t}
+hosting all the values @emph{and} initializes it. Once you are done with
+the dataset, be sure to clean up all the allocated spaces with
address@hidden
address@hidden deftypefun
+
@deftypefun void gal_data_initialize (gal_data_t @code{*data}, void
@code{*array}, uint8_t @code{type}, size_t @code{ndim}, size_t @code{*dsize},
struct wcsprm @code{*wcs}, int @code{clear}, size_t @code{minmapsize}, char
@code{*name}, char @code{*unit}, char @code{*comment})
Initialize the given data structure (@code{data}) with all the given
@@ -22463,21 +22474,10 @@ memory or it is used in multiple datasets, be sure to
set it to @code{NULL}
not have any zero values (a dimension of length zero is not defined).
@end deftypefun
address@hidden {gal_data_t *} gal_data_alloc (void @code{*array}, uint8_t
@code{type}, size_t @code{ndim}, size_t @code{*dsize}, struct wcsprm
@code{*wcs}, int @code{clear}, size_t @code{minmapsize}, char @code{*name},
char @code{*unit}, char @code{*comment})
-
-Dynamically allocate a @code{gal_data_t} and initialize it will all the
-given values. See the description of @code{gal_data_initialize} and
address@hidden data container} for more information. This function will often
-be the most frequently used because it allocates the @code{gal_data_t}
-hosting all the values @emph{and} initializes it. Once you are done with
-the dataset, be sure to clean up all the allocated spaces with
address@hidden
address@hidden deftypefun
-
@deftypefun void gal_data_free_contents (gal_data_t @code{*data})
Free all the address@hidden pointers in @code{gal_data_t}. If @code{data}
is actually a tile (@code{data->block!=NULL}, see @ref{Tessellation
-library}), then @code{tile->array} is not freed. For a complete description
+library}), then @code{data->array} is not freed. For a complete description
of @code{gal_data_t} and its contents, see @ref{Generic data container}.
@end deftypefun
diff --git a/lib/data.c b/lib/data.c
index b1e40a5..45b4762 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -63,6 +63,35 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/*********************************************************************/
/************* Allocation *******************/
/*********************************************************************/
+/* Allocate a data structure based on the given parameters. If you want to
+ force the array into the hdd/ssd (mmap it), then set minmapsize=-1
+ (largest possible size_t value), in this way, no file will be larger. */
+gal_data_t *
+gal_data_alloc(void *array, uint8_t type, size_t ndim, size_t *dsize,
+ struct wcsprm *wcs, int clear, size_t minmapsize,
+ char *name, char *unit, char *comment)
+{
+ gal_data_t *out;
+
+ /* Allocate the space for the actual structure. */
+ errno=0;
+ out=malloc(sizeof *out);
+ if(out==NULL)
+ error(EXIT_FAILURE, errno, "%s: %zu bytes for gal_data_t",
+ __func__, sizeof *out);
+
+ /* Initialize the allocated array. */
+ gal_data_initialize(out, array, type, ndim, dsize, wcs, clear, minmapsize,
+ name, unit, comment);
+
+ /* Return the final structure. */
+ return out;
+}
+
+
+
+
+
/* Initialize the data structure.
Some notes:
@@ -185,35 +214,6 @@ gal_data_initialize(gal_data_t *data, void *array, uint8_t
type,
-/* Allocate a data structure based on the given parameters. If you want to
- force the array into the hdd/ssd (mmap it), then set minmapsize=-1
- (largest possible size_t value), in this way, no file will be larger. */
-gal_data_t *
-gal_data_alloc(void *array, uint8_t type, size_t ndim, size_t *dsize,
- struct wcsprm *wcs, int clear, size_t minmapsize,
- char *name, char *unit, char *comment)
-{
- gal_data_t *out;
-
- /* Allocate the space for the actual structure. */
- errno=0;
- out=malloc(sizeof *out);
- if(out==NULL)
- error(EXIT_FAILURE, errno, "%s: %zu bytes for gal_data_t",
- __func__, sizeof *out);
-
- /* Initialize the allocated array. */
- gal_data_initialize(out, array, type, ndim, dsize, wcs, clear, minmapsize,
- name, unit, comment);
-
- /* Return the final structure. */
- return out;
-}
-
-
-
-
-
/* Free the allocated contents of a data structure, not the structure
itsself. The reason that this function is separate from `gal_data_free'
is that the data structure might be allocated as an array (statically
diff --git a/lib/gnuastro/data.h b/lib/gnuastro/data.h
index 590917f..32adbd7 100644
--- a/lib/gnuastro/data.h
+++ b/lib/gnuastro/data.h
@@ -232,17 +232,17 @@ typedef struct gal_data_t
/*********************************************************************/
/************* allocation *******************/
/*********************************************************************/
-void
-gal_data_initialize(gal_data_t *data, void *array, uint8_t type, size_t ndim,
- size_t *dsize, struct wcsprm *wcs, int clear,
- size_t minmapsize, char *name, char *unit, char *comment);
-
gal_data_t *
gal_data_alloc(void *array, uint8_t type, size_t ndim, size_t *dsize,
struct wcsprm *wcs, int clear, size_t minmapsize,
char *name, char *unit, char *comment);
void
+gal_data_initialize(gal_data_t *data, void *array, uint8_t type, size_t ndim,
+ size_t *dsize, struct wcsprm *wcs, int clear,
+ size_t minmapsize, char *name, char *unit, char *comment);
+
+void
gal_data_free_contents(gal_data_t *data);
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 653e5c0: gal_data_alloc defined before gal_data_initialize in code and book,
Mohammad Akhlaghi <=