PageRenderTime 14ms CodeModel.GetById 7ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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