move_alloc.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Generic implementation of the MOVE_ALLOC intrinsic
  2. Copyright (C) 2006-2022 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. extern void move_alloc (gfc_array_char *, gfc_array_char *);
  22. export_proto(move_alloc);
  23. void
  24. move_alloc (gfc_array_char * from, gfc_array_char * to)
  25. {
  26. int i;
  27. free (to->base_addr);
  28. for (i = 0; i < GFC_DESCRIPTOR_RANK (from); i++)
  29. {
  30. GFC_DIMENSION_SET(to->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
  31. GFC_DESCRIPTOR_UBOUND(from,i),
  32. GFC_DESCRIPTOR_STRIDE(from,i));
  33. GFC_DIMENSION_SET(from->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
  34. GFC_DESCRIPTOR_LBOUND(from,i), 0);
  35. }
  36. to->offset = from->offset;
  37. GFC_DTYPE_COPY(to,from);
  38. to->base_addr = from->base_addr;
  39. from->base_addr = NULL;
  40. }
  41. extern void move_alloc_c (gfc_array_char *, GFC_INTEGER_4,
  42. gfc_array_char *, GFC_INTEGER_4);
  43. export_proto(move_alloc_c);
  44. void
  45. move_alloc_c (gfc_array_char * from,
  46. GFC_INTEGER_4 from_length __attribute__((unused)),
  47. gfc_array_char * to,
  48. GFC_INTEGER_4 to_length __attribute__((unused)))
  49. {
  50. move_alloc (from, to);
  51. }