/src/wrappers/common/library/obsolete/expanded_wrapper.e

http://github.com/tybor/Liberty · Specman e · 71 lines · 41 code · 8 blank · 22 comment · 2 complexity · 480eec753cf0b7b1eaeb201945559c94 MD5 · raw file

  1. indexing
  2. description:
  3. "."
  4. copyright:
  5. "[
  6. Copyright (C) 2008 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. -- WARNING: This class will be not useful anymore when external types will
  23. -- be available and fully tested.
  24. inherit
  25. C_STRUCT
  26. redefine allocate
  27. end
  28. C_OWNED
  29. INTERNALS_HANDLER
  30. undefine copy, is_equal
  31. end
  32. feature {} --
  33. allocate is
  34. do
  35. handle := alloca(struct_size)
  36. end
  37. alloca (a_size: INTEGER): POINTER is
  38. -- The alloca() function allocates size bytes of space in the
  39. -- stack frame of the caller. This temporary space is
  40. -- automatically freed when the function that called alloca()
  41. -- returns to its caller.
  42. -- The alloca() function returns a pointer to the beginning of
  43. -- the allocated space. If the allocation causes stack
  44. -- overflow, program behavior is undefined.
  45. -- The alloca() function is machine- and compiler-dependent.
  46. -- For certain applications, its use can improve efficiency
  47. -- compared to the use of malloc(3) plus free(3). In certain
  48. -- cases, it can also simplify memory deallocation in
  49. -- applications that use longjmp(3) or siglongjmp(3).
  50. -- Otherwise, its use is discouraged.
  51. -- Because the space allocated by alloca() is allocated
  52. -- within the stack frame, that space is automatically freed
  53. -- if the function return is jumped over by a call to
  54. -- longjmp(3) or siglongjmp(3).
  55. require
  56. positive: a_size > 0
  57. external "C use <alloca.h>"
  58. end
  59. invariant
  60. used_in_expanded_types: to_internals.type_is_expanded
  61. -- When using previous versions of the compiler (<2.3)
  62. -- this invariant would become `is_expanded_type'
  63. end -- class EXPANDED_WRAPPER