ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
utilMem.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "abc_global.h"
Include dependency graph for utilMem.c:

Go to the source code of this file.

Classes

struct  Vec_Mem_t_
 

Macros

#define ABC_MEM_ALLOC(type, num)
 
#define ABC_MEM_CALLOC(type, num)
 
#define ABC_MEM_FALLOC(type, num)
 
#define ABC_MEM_FREE(obj)
 
#define ABC_MEM_REALLOC(type, obj, num)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
 DECLARATIONS ///.
 

Functions

void * Util_MemRecAlloc (void *pMem)
 BASIC TYPES ///.
 
void * Util_MemRecFree (void *pMem)
 
int Util_ComparePointers (void **pp1, void **pp2)
 
void Util_MemRecRecycle ()
 
void Util_MemRecStart ()
 
void Util_MemRecQuit ()
 
int Util_MemRecIsSet ()
 

Variables

void * s_vAllocs = NULL
 INCLUDES ///.
 
void * s_vFrees = NULL
 
int s_fInterrupt = 0
 

Macro Definition Documentation

◆ ABC_MEM_ALLOC

#define ABC_MEM_ALLOC ( type,
num )
Value:
((type *) malloc(sizeof(type) * (num)))
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
char * malloc()

Definition at line 47 of file utilMem.c.

◆ ABC_MEM_CALLOC

#define ABC_MEM_CALLOC ( type,
num )
Value:
((type *) calloc((num), sizeof(type)))
char * calloc()

Definition at line 48 of file utilMem.c.

◆ ABC_MEM_FALLOC

#define ABC_MEM_FALLOC ( type,
num )
Value:
((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num)))
char * memset()

Definition at line 49 of file utilMem.c.

◆ ABC_MEM_FREE

#define ABC_MEM_FREE ( obj)
Value:
((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
VOID_HACK free()

Definition at line 50 of file utilMem.c.

◆ ABC_MEM_REALLOC

#define ABC_MEM_REALLOC ( type,
obj,
num )
Value:
((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
((type *) malloc(sizeof(type) * (num))))
char * realloc()

Definition at line 51 of file utilMem.c.

51#define ABC_MEM_REALLOC(type, obj, num) \
52 ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
53 ((type *) malloc(sizeof(type) * (num))))

Typedef Documentation

◆ Vec_Mem_t

typedef typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t

DECLARATIONS ///.

CFile****************************************************************

FileName [utilMem.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Memory recycling utilities.]

Synopsis [Memory recycling utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
utilMem.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 35 of file utilMem.c.

Function Documentation

◆ Util_ComparePointers()

int Util_ComparePointers ( void ** pp1,
void ** pp2 )

Function*************************************************************

Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file utilMem.c.

209{
210 if ( *pp1 < *pp2 )
211 return -1;
212 if ( *pp1 > *pp2 )
213 return 1;
214 return 0;
215}
Here is the caller graph for this function:

◆ Util_MemRecAlloc()

void * Util_MemRecAlloc ( void * pMem)

BASIC TYPES ///.

Function*************************************************************

Synopsis [Remembers an allocated pointer.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file utilMem.c.

173{
174 if ( s_vAllocs )
175 Vec_MemPush( (Vec_Mem_t *)s_vAllocs, pMem );
176 return pMem;
177}
void * s_vAllocs
INCLUDES ///.
Definition utilMem.c:43
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
Definition utilMem.c:35

◆ Util_MemRecFree()

void * Util_MemRecFree ( void * pMem)

Function*************************************************************

Synopsis [Remembers a deallocated pointer.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file utilMem.c.

191{
192 if ( s_vFrees )
193 Vec_MemPush( (Vec_Mem_t *)s_vFrees, pMem );
194 return pMem;
195}
void * s_vFrees
Definition utilMem.c:44

◆ Util_MemRecIsSet()

int Util_MemRecIsSet ( )

Function*************************************************************

Synopsis [Starts memory structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file utilMem.c.

331{
332 return s_vAllocs != NULL && s_vFrees != NULL;
333}

◆ Util_MemRecQuit()

void Util_MemRecQuit ( )

Function*************************************************************

Synopsis [Quits memory structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 312 of file utilMem.c.

313{
314 assert( s_vAllocs != NULL && s_vFrees != NULL );
315 Vec_MemFree( (Vec_Mem_t *)s_vAllocs );
316 Vec_MemFree( (Vec_Mem_t *)s_vFrees );
317}
#define assert(ex)
Definition util_old.h:213

◆ Util_MemRecRecycle()

void Util_MemRecRecycle ( )

Function*************************************************************

Synopsis [Recycles the accumulated memory.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file utilMem.c.

273{
274 Vec_Mem_t * vMerge;
275 assert( s_vAllocs == NULL );
276 assert( s_vFrees == NULL );
277 Vec_MemSort( (Vec_Mem_t *)s_vAllocs, (int (*)())Util_ComparePointers );
278 Vec_MemSort( (Vec_Mem_t *)s_vFrees, (int (*)())Util_ComparePointers );
279 vMerge = (Vec_Mem_t *)Vec_MemTwoMerge( (Vec_Mem_t *)s_vAllocs, (Vec_Mem_t *)s_vFrees );
280 Vec_MemFree( vMerge );
281}
int Util_ComparePointers(void **pp1, void **pp2)
Definition utilMem.c:208
Here is the call graph for this function:

◆ Util_MemRecStart()

void Util_MemRecStart ( )

Function*************************************************************

Synopsis [Starts memory structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 294 of file utilMem.c.

295{
296 assert( s_vAllocs == NULL && s_vFrees == NULL );
297 s_vAllocs = Vec_MemAlloc( 1000 );
298 s_vFrees = Vec_MemAlloc( 1000 );
299}

Variable Documentation

◆ s_fInterrupt

int s_fInterrupt = 0

Definition at line 45 of file utilMem.c.

◆ s_vAllocs

void* s_vAllocs = NULL

INCLUDES ///.

CFile****************************************************************

FileName [utilInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Memory recycling utilities.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
utilInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS ///

Definition at line 43 of file utilMem.c.

◆ s_vFrees

void* s_vFrees = NULL

Definition at line 44 of file utilMem.c.