/src/wrappers/common/attic/expanded_wrapper.e

http://github.com/tybor/Liberty · Specman e · 69 lines · 41 code · 8 blank · 20 comment · 2 complexity · 4b8a63882581b45efcf35d1740177142 MD5 · raw file

  1. note
  2. description:
  3. "."
  4. copyright:
  5. "[
  6. Copyright (C) 2008-2017: Paolo Redaelli
  7. This library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public License
  9. as published by the Free Software Foundation; either version 2.1 of
  10. the License, or (at your option) any later version.
  11. This library is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. 02110-1301 USA
  19. ]"
  20. deferred class EXPANDED_WRAPPER
  21. -- A wrapper for an object on the stack
  22. inherit
  23. C_STRUCT
  24. redefine allocate
  25. end
  26. C_OWNED
  27. INTERNALS_HANDLER
  28. undefine copy, is_equal
  29. end
  30. feature {} --
  31. allocate
  32. do
  33. handle := alloca(struct_size)
  34. end
  35. alloca (a_size: INTEGER): POINTER
  36. -- The alloca() function allocates size bytes of space in the
  37. -- stack frame of the caller. This temporary space
  38. -- automatically freed when the function that called alloca()
  39. -- returns to its caller.
  40. -- The alloca() function returns a pointer to the beginning of
  41. -- the allocated space. If the allocation causes stack
  42. -- overflow, program behavior is undefined.
  43. -- The alloca() function is machine- and compiler-dependent.
  44. -- For certain applications, its use can improve efficiency
  45. -- compared to the use of malloc(3) plus free(3). In certain
  46. -- cases, it can also simplify memory deallocation in
  47. -- applications that use longjmp(3) or siglongjmp(3).
  48. -- Otherwise, its use is discouraged.
  49. -- Because the space allocated by alloca() is allocated
  50. -- within the stack frame, that space is automatically freed
  51. -- if the function return is jumped over by a call to
  52. -- longjmp(3) or siglongjmp(3).
  53. require
  54. positive: a_size > 0
  55. external "C use <alloca.h>"
  56. end
  57. invariant
  58. used_in_expanded_types: to_internals.type_is_expanded
  59. -- When using previous versions of the compiler (<2.3)
  60. -- this invariant would become `is_expanded_type'
  61. end -- class EXPANDED_WRAPPER