File: clb_plocalstacks.c

package info (click to toggle)
eprover 3.2.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,504 kB
  • sloc: ansic: 104,396; csh: 13,135; python: 11,207; awk: 5,825; makefile: 554; sh: 400
file content (52 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*-----------------------------------------------------------------------

File  : clb_plocalstacks.c

Author: Martin Möhrmann

Contents

  Stack implementation with macros that use local variables.

  Copyright 2016 by the author.
  This code is released under the GNU General Public Licence and
  the GNU Lesser General Public License.
  See the file COPYING in the main E directory for details..
  Run "eprover -h" for contact information.

  Created: Sat Jun 4 20:30:20 2016

  -----------------------------------------------------------------------*/

#include <clb_memory.h>

/*-----------------------------------------------------------------------
//
// Function: PLocalStackGrow()
//
//   Grow stack to have room for at least space new items.
//
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

__attribute__ ((noinline)) size_t PLocalStackGrow(void** *data, size_t size, size_t space)
{
   size_t old_size = size;
   while(size <= (old_size+space))
   {
      size *= 2;
   }
   void* tmp = SizeMalloc(size * sizeof(void*));
   memcpy(tmp, *data, old_size * sizeof(void*));
   SizeFree(*data, old_size * sizeof(void*));
   *data = tmp;
   return size;
}

/*---------------------------------------------------------------------*/
/*                        End of File                                  */
/*---------------------------------------------------------------------*/