Переглянути джерело

Eliminate G_copy(); replace with memcpy() or assignment

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40836 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 15 роки тому
батько
коміт
88abdb3fab

+ 5 - 5
general/g.region/main.c

@@ -414,7 +414,7 @@ int main(int argc, char *argv[])
 	    G_fatal_error(_("Unable to open 3dview file <%s> in <%s>"), name,
 			  mapset);
 
-	G_copy(&temp_window, &window, sizeof(window));
+	temp_window = window;
 
 	if (0 > (ret = G_get_3dview(name, mapset, &v)))
 	    G_fatal_error(_("Unable to read 3dview file <%s> in <%s>"), name,
@@ -452,7 +452,7 @@ int main(int argc, char *argv[])
 		G_fatal_error(_("Raster map <%s> not found"), rast_name);
 	    Rast_get_cellhd(rast_name, mapset, &temp_window);
 	    if (!first) {
-		G_copy(&window, &temp_window, sizeof(window));
+		window = temp_window;
 		first = 1;
 	    }
 	    else {
@@ -500,7 +500,7 @@ int main(int argc, char *argv[])
 	    if (!mapset)
 		G_fatal_error(_("Vector map <%s> not found"), vect_name);
 
-	    G_copy(&temp_window, &window, sizeof(window));
+	    temp_window = window;
 
 	    Vect_set_open_level(2);
 	    if (2 != Vect_open_old(&Map, vect_name, mapset))
@@ -517,7 +517,7 @@ int main(int argc, char *argv[])
 	    map_window.bottom = box.B;
 
 	    if (!first) {
-		G_copy(&window, &map_window, sizeof(window));
+		window = map_window;
 		first = 1;
 	    }
 	    else {
@@ -788,7 +788,7 @@ int main(int argc, char *argv[])
 
     /* save= */
     if ((name = parm.save->answer)) {
-	G_copy(&temp_window, &window, sizeof(window));
+	temp_window = window;
 	G_adjust_Cell_head3(&temp_window, 0, 0, 0);
 	if (G__put_window(&temp_window, "windows", name) < 0)
 	    G_fatal_error(_("Unable to set region <%s>"), name);

+ 1 - 1
imagery/i.rectify/rectify.c

@@ -45,7 +45,7 @@ int rectify(char *name, char *mapset, char *result, int order)
     rast = (void *)G_calloc(Rast_window_cols() + 1, Rast_cell_size(map_type));
     Rast_set_null_value(rast, Rast_window_cols() + 1, map_type);
 
-    G_copy(&win, &target_window, sizeof(win));
+    win = target_window;
 
     win.west += win.ew_res / 2;
     ncols = target_window.cols;

+ 0 - 3
include/gisdefs.h

@@ -124,9 +124,6 @@ int G_num_standard_colors(void);
 int G_insert_commas(char *);
 void G_remove_commas(char *);
 
-/* copy.c */
-void G_copy(void *, const void *, int);
-
 /* copy_dir.c */
 int G_recursive_copy(const char *, const char *);
 

+ 1 - 3
lib/g3d/g3dregion.c

@@ -199,8 +199,6 @@ void G3d_adjustRegionRes(G3D_Region * region)
  * \brief 
  *
  * Copies the values of <em>regionSrc</em> into <em>regionDst</em>.
- * (The unfortunate order of parameters was chosen in order to conform to the
- * order used in <em>G_copy ()</em>).
  *
  *  \param regionDest
  *  \param regionSrc
@@ -209,7 +207,7 @@ void G3d_adjustRegionRes(G3D_Region * region)
 
 void G3d_regionCopy(G3D_Region * regionDest, G3D_Region * regionSrc)
 {
-    G_copy(regionDest, regionSrc, sizeof(G3D_Region));
+    *regionDest = *regionSrc;
 }
 
 /*---------------------------------------------------------------------------*/

+ 0 - 33
lib/gis/copy.c

@@ -1,33 +0,0 @@
-
-/**
- * \file copy.c
- *
- * \brief GIS Library - Memory copy functions.
- *
- * (C) 2001-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author GRASS GIS Development Team
- *
- * \date 1999-2008
- */
-
-#include <grass/gis.h>
-#include <string.h>
-
-/**
- * \brief Copies <b>n</b> bytes starting at address <b>b</b> into 
- * address <b>a</b>.
- *
- * \param[out] a destination (to)
- * \param[in]  b source (from)
- * \param[in]  n number of bytes to copy
- *
- * \return
- */
-void G_copy(void *a, const void *b, int n)
-{
-    memcpy(a, b, n);
-}

+ 1 - 1
lib/gis/env.c

@@ -496,7 +496,7 @@ void G__create_alt_env(void)
     int i;
 
     /* copy env to env2 */
-    G_copy(&st->env2, &st->env, sizeof(st->env));
+    st->env2 = st->env;
     
     st->env.count = 0;
     st->env.size = 0;

+ 1 - 1
lib/gis/parser.c

@@ -1155,7 +1155,7 @@ static void split_opts(void)
 
 		if (len > 0) {	/* skip ,, */
 		    opt->answers[ans_num] = (char *)G_malloc(len + 1);
-		    G_copy(opt->answers[ans_num], ptr1, len);
+		    memcpy(opt->answers[ans_num], ptr1, len);
 		    opt->answers[ans_num][len] = 0;
 
 		    ans_num++;

+ 2 - 7
lib/gis/set_window.c

@@ -27,7 +27,7 @@
 void G_get_set_window(struct Cell_head *window)
 {
     G__init_window();
-    G_copy(window, &G__.window, sizeof(*window));
+    *window = G__.window;
 }
 
 /*!
@@ -41,15 +41,10 @@ void G_get_set_window(struct Cell_head *window)
 void G_set_window(struct Cell_head *window)
 {
     /* adjust window, check for valid window */
-    /* adjust the real one, not a copy
-       G_copy (&twindow, window, sizeof(struct Cell_head));
-       window = &twindow;
-     */
 
     G_adjust_Cell_head(window, 0, 0);
 
     /* copy the window to the current window */
-    G_copy((char *)&G__.window, (char *)window, sizeof(*window));
-
+    G__.window = *window;
     G__.window_set = 1;
 }

+ 1 - 1
lib/gis/wind_2_box.c

@@ -35,7 +35,7 @@ void G_adjust_window_to_box(const struct Cell_head *src,
 {
     double ew, ns;
 
-    G_copy((char *)dst, (char *)src, sizeof(*dst));
+    *dst = *src;
 
     /* calculate the effective resolutions */
     ns = (src->ns_res * src->rows) / rows;

+ 3 - 3
lib/raster/opencell.c

@@ -266,7 +266,7 @@ int Rast__open_old(const char *name, const char *mapset)
     fcb->map_type = MAP_TYPE;
 
     /* Save cell header */
-    G_copy((char *)&fcb->cellhd, (char *)&cellhd, sizeof(cellhd));
+    fcb->cellhd = cellhd;
 
     /* allocate null bitstream buffers for reading null rows */
     fcb->null_fd = -1;
@@ -285,7 +285,7 @@ int Rast__open_old(const char *name, const char *mapset)
 
     /* if reclass, copy reclass structure */
     if ((fcb->reclass_flag = reclass_flag))
-	G_copy(&fcb->reclass, &reclass, sizeof(reclass));
+	fcb->reclass = reclass;
 
     fcb->gdal = gdal;
     if (!gdal)
@@ -619,7 +619,7 @@ static int open_raster_new(const char *name, int open_mode,
      * for compressed writing
      *   allocate space to hold the row address array
      */
-    G_copy(&fcb->cellhd, &R__.wr_window, sizeof(fcb->cellhd));
+    fcb->cellhd = R__.wr_window;
 
     if (open_mode == OPEN_NEW_COMPRESSED && fcb->map_type == CELL_TYPE) {
 	fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));

+ 1 - 1
lib/raster/raster.c

@@ -75,7 +75,7 @@ int Rast_raster_cmp(const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
 void Rast_raster_cpy(void *v1, const void *v2, int n,
 		     RASTER_MAP_TYPE data_type)
 {
-    G_copy(v1, v2, n * Rast_cell_size(data_type));
+    memcpy(v1, v2, n * Rast_cell_size(data_type));
 }
 
 /*!

+ 1 - 1
raster/r.region/main.c

@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
 
     Rast_get_cellhd(name, G_mapset(), &cellhd);
 
-    G_copy(&window, &cellhd, sizeof(window));
+    window = cellhd;
 
     if (flag.dflt->answer)
 	G_get_default_window(&window);