move_alloc.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Generic implementation of the MOVE_ALLOC intrinsic
  2. Copyright (C) 2006-2015 Free Software Foundation, Inc.
  3. Contributed by Paul Thomas
  4. This file is part of the GNU Fortran runtime library (libgfortran).
  5. Libgfortran is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public
  7. License as published by the Free Software Foundation; either
  8. version 3 of the License, or (at your option) any later version.
  9. Ligbfortran is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #include "libgfortran.h"
  21. #include <stdlib.h>
  22. extern void move_alloc (gfc_array_char *, gfc_array_char *);
  23. export_proto(move_alloc);
  24. void
  25. move_alloc (gfc_array_char * from, gfc_array_char * to)
  26. {
  27. int i;
  28. free (to->base_addr);
  29. for (i = 0; i < GFC_DESCRIPTOR_RANK (from); i++)
  30. {
  31. GFC_DIMENSION_SET(to->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
  32. GFC_DESCRIPTOR_UBOUND(from,i),
  33. GFC_DESCRIPTOR_STRIDE(from,i));
  34. GFC_DIMENSION_SET(from->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
  35. GFC_DESCRIPTOR_LBOUND(from,i), 0);
  36. }
  37. to->offset = from->offset;
  38. to->dtype = from->dtype;
  39. to->base_addr = from->base_addr;
  40. from->base_addr = NULL;
  41. }
  42. extern void move_alloc_c (gfc_array_char *, GFC_INTEGER_4,
  43. gfc_array_char *, GFC_INTEGER_4);
  44. export_proto(move_alloc_c);
  45. void
  46. move_alloc_c (gfc_array_char * from,
  47. GFC_INTEGER_4 from_length __attribute__((unused)),
  48. gfc_array_char * to,
  49. GFC_INTEGER_4 to_length __attribute__((unused)))
  50. {
  51. move_alloc (from, to);
  52. }