abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
utilNam.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "abc_global.h"
#include "misc/vec/vec.h"
#include "utilNam.h"

Go to the source code of this file.

Data Structures

struct  Abc_Nam_t_
 DECLARATIONS ///. More...
 

Functions

static char * Abc_NamHandleToStr (Abc_Nam_t *p, int h)
 
static int Abc_NamIntToHandle (Abc_Nam_t *p, int i)
 
static char * Abc_NamIntToStr (Abc_Nam_t *p, int i)
 
static int Abc_NamIntToNext (Abc_Nam_t *p, int i)
 
static int * Abc_NamIntToNextP (Abc_Nam_t *p, int i)
 
Abc_Nam_tAbc_NamStart (int nObjs, int nAveSize)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NamStop (Abc_Nam_t *p)
 
void Abc_NamPrint (Abc_Nam_t *p)
 
Abc_Nam_tAbc_NamRef (Abc_Nam_t *p)
 
void Abc_NamDeref (Abc_Nam_t *p)
 
int Abc_NamObjNumMax (Abc_Nam_t *p)
 
int Abc_NamMemUsed (Abc_Nam_t *p)
 
int Abc_NamMemAlloc (Abc_Nam_t *p)
 
int Abc_NamStrHash (const char *pStr, const char *pLim, int nTableSize)
 
static int Abc_NamStrcmp (char *pStr, char *pLim, char *pThis)
 
static int * Abc_NamStrHashFind (Abc_Nam_t *p, const char *pStr, const char *pLim)
 
void Abc_NamStrHashResize (Abc_Nam_t *p)
 
int Abc_NamStrFind (Abc_Nam_t *p, char *pStr)
 
int Abc_NamStrFindLim (Abc_Nam_t *p, char *pStr, char *pLim)
 
int Abc_NamStrFindOrAdd (Abc_Nam_t *p, char *pStr, int *pfFound)
 
int Abc_NamStrFindOrAddLim (Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
 
char * Abc_NamStr (Abc_Nam_t *p, int NameId)
 
Vec_Int_tAbc_NamComputeIdMap (Abc_Nam_t *p1, Abc_Nam_t *p2)
 
int Abc_NamReportCommon (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2)
 
char * Abc_NamReportUnique (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2)
 

Function Documentation

Vec_Int_t* Abc_NamComputeIdMap ( Abc_Nam_t p1,
Abc_Nam_t p2 
)

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

Synopsis [For each ID of the first manager, gives ID of the second one.]

Description []

SideEffects []

SeeAlso []

Definition at line 495 of file utilNam.c.

496 {
497  Vec_Int_t * vMap;
498  char * pThis;
499  int * piPlace, iHandle1, i;
500  if ( p1 == p2 )
502  vMap = Vec_IntStart( Abc_NamObjNumMax(p1) );
503  Vec_IntForEachEntryStart( p1->vInt2Handle, iHandle1, i, 1 )
504  {
505  pThis = Abc_NamHandleToStr( p1, iHandle1 );
506  piPlace = Abc_NamStrHashFind( p2, pThis, NULL );
507  Vec_IntWriteEntry( vMap, i, *piPlace );
508 // Abc_Print( 1, "%d->%d ", i, *piPlace );
509  }
510  return vMap;
511 }
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
void Abc_NamDeref ( Abc_Nam_t p)

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

Synopsis [Dereferences the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file utilNam.c.

168 {
169  if ( p == NULL )
170  return;
171  if ( --p->nRefs == 0 )
172  Abc_NamStop( p );
173 }
void Abc_NamStop(Abc_Nam_t *p)
Definition: utilNam.c:110
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char* Abc_NamHandleToStr ( Abc_Nam_t p,
int  h 
)
inlinestatic

Definition at line 57 of file utilNam.c.

57 { return (char *)(p->pStore + h); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_NamIntToHandle ( Abc_Nam_t p,
int  i 
)
inlinestatic

Definition at line 58 of file utilNam.c.

58 { return Vec_IntEntry(p->vInt2Handle, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_NamIntToNext ( Abc_Nam_t p,
int  i 
)
inlinestatic

Definition at line 60 of file utilNam.c.

60 { return Vec_IntEntry(p->vInt2Next, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int* Abc_NamIntToNextP ( Abc_Nam_t p,
int  i 
)
inlinestatic

Definition at line 61 of file utilNam.c.

61 { return Vec_IntEntryP(p->vInt2Next, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static char* Abc_NamIntToStr ( Abc_Nam_t p,
int  i 
)
inlinestatic

Definition at line 59 of file utilNam.c.

static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_NamIntToHandle(Abc_Nam_t *p, int i)
Definition: utilNam.c:58
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
int Abc_NamMemAlloc ( Abc_Nam_t p)

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

Synopsis [Reports memory usage of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file utilNam.c.

222 {
223  if ( p == NULL )
224  return 0;
225  return sizeof(Abc_Nam_t) + p->nStore + sizeof(int) * p->nBins +
226  sizeof(int) * (p->vInt2Handle->nCap + p->vInt2Next->nCap);
227 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition: utilNam.h:39
int Abc_NamMemUsed ( Abc_Nam_t p)

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

Synopsis [Reports memory usage of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file utilNam.c.

203 {
204  if ( p == NULL )
205  return 0;
206  return sizeof(Abc_Nam_t) + p->iHandle + sizeof(int) * p->nBins +
207  sizeof(int) * (p->vInt2Handle->nSize + p->vInt2Next->nSize);
208 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition: utilNam.h:39
int Abc_NamObjNumMax ( Abc_Nam_t p)

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

Synopsis [Returns the number of used entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file utilNam.c.

187 {
188  return Vec_IntSize(p->vInt2Handle);
189 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Abc_NamPrint ( Abc_Nam_t p)

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

Synopsis [Prints manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file utilNam.c.

132 {
133  int h, i;
134  Vec_IntForEachEntryStart( p->vInt2Handle, h, i, 1 )
135  Abc_Print( 1, "%d=\n%s\n", i, Abc_NamHandleToStr(p, h) );
136 // Abc_Print( 1, "\n" );
137 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
Abc_Nam_t* Abc_NamRef ( Abc_Nam_t p)

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

Synopsis [References the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file utilNam.c.

151 {
152  p->nRefs++;
153  return p;
154 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Abc_NamReportCommon ( Vec_Int_t vNameIds1,
Abc_Nam_t p1,
Abc_Nam_t p2 
)

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

Synopsis [Returns the number of common names in the array.]

Description [The array contains name IDs in the first manager. The procedure returns the number of entries that correspond to names in the first manager that appear in the second manager.]

SideEffects []

SeeAlso []

Definition at line 526 of file utilNam.c.

527 {
528  int i, Entry, Counter = 0;
529  Vec_IntForEachEntry( vNameIds1, Entry, i )
530  {
531  assert( Entry > 0 && Entry < Abc_NamObjNumMax(p1) );
532  Counter += (Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) > 0);
533 // if ( Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) == 0 )
534 // Abc_Print( 1, "unique name <%s>\n", Abc_NamStr(p1, Entry) );
535  }
536  return Counter;
537 }
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
static int Counter
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition: utilNam.c:372
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
char* Abc_NamReportUnique ( Vec_Int_t vNameIds1,
Abc_Nam_t p1,
Abc_Nam_t p2 
)

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

Synopsis [Returns the name that appears in p1 does not appear in p2.]

Description []

SideEffects []

SeeAlso []

Definition at line 550 of file utilNam.c.

551 {
552  int i, Entry;
553  Vec_IntForEachEntry( vNameIds1, Entry, i )
554  {
555  assert( Entry > 0 && Entry < Abc_NamObjNumMax(p1) );
556  if ( Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) == 0 )
557  return Abc_NamStr(p1, Entry);
558  }
559  return NULL;
560 }
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition: utilNam.c:372
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Abc_Nam_t* Abc_NamStart ( int  nObjs,
int  nAveSize 
)

FUNCTION DEFINITIONS ///.

FUNCTION DECLARATIONS ///.

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

Synopsis [Creates manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file utilNam.c.

79 {
80  Abc_Nam_t * p;
81  if ( nObjs == 0 )
82  nObjs = 16;
83  p = ABC_CALLOC( Abc_Nam_t, 1 );
84  p->nStore = ((nObjs * (nAveSize + 1) + 16) / 4) * 4;
85  p->pStore = ABC_ALLOC( char, p->nStore );
86  p->nBins = Abc_PrimeCudd( nObjs );
87  p->pBins = ABC_CALLOC( int, p->nBins );
88  // 0th object is unused
89  p->vInt2Handle = Vec_IntAlloc( nObjs ); Vec_IntPush( p->vInt2Handle, -1 );
90  p->vInt2Next = Vec_IntAlloc( nObjs ); Vec_IntPush( p->vInt2Next, -1 );
91  p->iHandle = 4;
92  memset( p->pStore, 0, 4 );
93 //Abc_Print( 1, "Starting nam with %d bins.\n", p->nBins );
94  // start reference counting
95  p->nRefs = 1;
96  return p;
97 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition: utilNam.h:39
void Abc_NamStop ( Abc_Nam_t p)

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

Synopsis [Deletes manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file utilNam.c.

111 {
112 //Abc_Print( 1, "Starting nam with %d bins.\n", p->nBins );
113  Vec_IntFree( p->vInt2Handle );
114  Vec_IntFree( p->vInt2Next );
115  ABC_FREE( p->pStore );
116  ABC_FREE( p->pBins );
117  ABC_FREE( p );
118 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
char* Abc_NamStr ( Abc_Nam_t p,
int  NameId 
)

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

Synopsis [Returns name from name ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 479 of file utilNam.c.

480 {
481  return NameId? Abc_NamIntToStr(p, NameId) : NULL;
482 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Abc_NamIntToStr(Abc_Nam_t *p, int i)
Definition: utilNam.c:59
static int Abc_NamStrcmp ( char *  pStr,
char *  pLim,
char *  pThis 
)
inlinestatic

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

Synopsis [Returns place where this string is, or should be.]

Description []

SideEffects []

SeeAlso []

Definition at line 288 of file utilNam.c.

289 {
290  if ( pLim )
291  {
292  while ( pStr < pLim )
293  if ( *pStr++ != *pThis++ )
294  return 1;
295  return *pThis != '\0';
296  }
297  else
298  {
299  while ( *pStr )
300  if ( *pStr++ != *pThis++ )
301  return 1;
302  return *pThis != '\0';
303  }
304 }
int Abc_NamStrFind ( Abc_Nam_t p,
char *  pStr 
)

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

Synopsis [Returns the index of the string in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 372 of file utilNam.c.

373 {
374  return *Abc_NamStrHashFind( p, pStr, NULL );
375 }
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Abc_NamStrFindLim ( Abc_Nam_t p,
char *  pStr,
char *  pLim 
)

Definition at line 376 of file utilNam.c.

377 {
378  return *Abc_NamStrHashFind( p, pStr, pLim );
379 }
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Abc_NamStrFindOrAdd ( Abc_Nam_t p,
char *  pStr,
int *  pfFound 
)

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

Synopsis [Finds or adds the given name to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 392 of file utilNam.c.

393 {
394  int i, iHandleNew;
395  int *piPlace;
396  if ( !(pStr[0] != '\\' || pStr[strlen(pStr)-1] == ' ') )
397  {
398  for ( i = strlen(pStr) - 1; i >= 0; i-- )
399  if ( *pStr == ' ' )
400  break;
401  assert( i < (int)strlen(pStr) );
402  }
403  piPlace = Abc_NamStrHashFind( p, pStr, NULL );
404  if ( *piPlace )
405  {
406  if ( pfFound )
407  *pfFound = 1;
408  return *piPlace;
409  }
410  if ( pfFound )
411  *pfFound = 0;
412  iHandleNew = p->iHandle + strlen(pStr) + 1;
413  while ( p->nStore < iHandleNew )
414  {
415  p->nStore *= 3;
416  p->nStore /= 2;
417  p->pStore = ABC_REALLOC( char, p->pStore, p->nStore );
418  }
419  assert( p->nStore >= iHandleNew );
420  // create new handle
421  *piPlace = Vec_IntSize( p->vInt2Handle );
422  strcpy( Abc_NamHandleToStr( p, p->iHandle ), pStr );
423  Vec_IntPush( p->vInt2Handle, p->iHandle );
424  Vec_IntPush( p->vInt2Next, 0 );
425  p->iHandle = iHandleNew;
426  // extend the hash table
427  if ( Vec_IntSize(p->vInt2Handle) > 2 * p->nBins )
429  return Vec_IntSize(p->vInt2Handle) - 1;
430 }
void Abc_NamStrHashResize(Abc_Nam_t *p)
Definition: utilNam.c:329
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
char * strcpy()
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int strlen()
int Abc_NamStrFindOrAddLim ( Abc_Nam_t p,
char *  pStr,
char *  pLim,
int *  pfFound 
)

Definition at line 431 of file utilNam.c.

432 {
433  int iHandleNew;
434  int *piPlace;
435  char * pStore;
436  assert( pStr < pLim );
437  piPlace = Abc_NamStrHashFind( p, pStr, pLim );
438  if ( *piPlace )
439  {
440  if ( pfFound )
441  *pfFound = 1;
442  return *piPlace;
443  }
444  if ( pfFound )
445  *pfFound = 0;
446  iHandleNew = p->iHandle + (pLim - pStr) + 1;
447  while ( p->nStore < iHandleNew )
448  {
449  p->nStore *= 3;
450  p->nStore /= 2;
451  p->pStore = ABC_REALLOC( char, p->pStore, p->nStore );
452  }
453  assert( p->nStore >= iHandleNew );
454  // create new handle
455  *piPlace = Vec_IntSize( p->vInt2Handle );
456  pStore = Abc_NamHandleToStr( p, p->iHandle );
457  strncpy( pStore, pStr, pLim - pStr );
458  pStore[pLim - pStr] = 0;
459  Vec_IntPush( p->vInt2Handle, p->iHandle );
460  Vec_IntPush( p->vInt2Next, 0 );
461  p->iHandle = iHandleNew;
462  // extend the hash table
463  if ( Vec_IntSize(p->vInt2Handle) > 2 * p->nBins )
465  return Vec_IntSize(p->vInt2Handle) - 1;
466 }
void Abc_NamStrHashResize(Abc_Nam_t *p)
Definition: utilNam.c:329
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
char * strncpy()
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int Abc_NamStrHash ( const char *  pStr,
const char *  pLim,
int  nTableSize 
)

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

Synopsis [Computes hash value of the C-string.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file utilNam.c.

241 {
242  static int s_FPrimes[128] = {
243  1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
244  1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
245  2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
246  2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
247  3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
248  3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
249  4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
250  4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
251  5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
252  6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
253  6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
254  7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
255  8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
256  };
257  unsigned i, uHash;
258  if ( pLim )
259  {
260  for ( uHash = 0, i = 0; pStr+i < pLim; i++ )
261  if ( i & 1 )
262  uHash *= pStr[i] * s_FPrimes[i & 0x7F];
263  else
264  uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
265  }
266  else
267  {
268  for ( uHash = 0, i = 0; pStr[i]; i++ )
269  if ( i & 1 )
270  uHash *= pStr[i] * s_FPrimes[i & 0x7F];
271  else
272  uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
273  }
274  return uHash % nTableSize;
275 }
static int* Abc_NamStrHashFind ( Abc_Nam_t p,
const char *  pStr,
const char *  pLim 
)
inlinestatic

Definition at line 305 of file utilNam.c.

306 {
307  char * pThis;
308  int * pPlace = (int *)(p->pBins + Abc_NamStrHash( pStr, pLim, p->nBins ));
309  assert( *pStr );
310  for ( pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL;
311  pThis; pPlace = Abc_NamIntToNextP(p, *pPlace),
312  pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL )
313  if ( !Abc_NamStrcmp( (char *)pStr, (char *)pLim, pThis ) )
314  break;
315  return pPlace;
316 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Abc_NamIntToStr(Abc_Nam_t *p, int i)
Definition: utilNam.c:59
int Abc_NamStrHash(const char *pStr, const char *pLim, int nTableSize)
Definition: utilNam.c:240
if(last==0)
Definition: sparse_int.h:34
static int * Abc_NamIntToNextP(Abc_Nam_t *p, int i)
Definition: utilNam.c:61
#define assert(ex)
Definition: util_old.h:213
static int Abc_NamStrcmp(char *pStr, char *pLim, char *pThis)
Definition: utilNam.c:288
void Abc_NamStrHashResize ( Abc_Nam_t p)

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

Synopsis [Resizes the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file utilNam.c.

330 {
331  Vec_Int_t * vInt2HandleOld;
332  char * pThis;
333  int * piPlace, * pBinsOld, iHandleOld, i;//, clk = Abc_Clock();
334  assert( p->pBins != NULL );
335 // Abc_Print( 1, "Resizing names manager hash table from %6d to %6d. ", p->nBins, Abc_PrimeCudd( 3 * p->nBins ) );
336  // replace the table
337  pBinsOld = p->pBins;
338  p->nBins = Abc_PrimeCudd( 3 * p->nBins );
339  p->pBins = ABC_CALLOC( int, p->nBins );
340  // replace the handles array
341  vInt2HandleOld = p->vInt2Handle;
342  p->vInt2Handle = Vec_IntAlloc( 2 * Vec_IntSize(vInt2HandleOld) );
343  Vec_IntPush( p->vInt2Handle, -1 );
344  Vec_IntClear( p->vInt2Next ); Vec_IntPush( p->vInt2Next, -1 );
345  // rehash the entries from the old table
346  Vec_IntForEachEntryStart( vInt2HandleOld, iHandleOld, i, 1 )
347  {
348  pThis = Abc_NamHandleToStr( p, iHandleOld );
349  piPlace = Abc_NamStrHashFind( p, pThis, NULL );
350  assert( *piPlace == 0 );
351  *piPlace = Vec_IntSize( p->vInt2Handle );
352  assert( Vec_IntSize( p->vInt2Handle ) == i );
353  Vec_IntPush( p->vInt2Handle, iHandleOld );
354  Vec_IntPush( p->vInt2Next, 0 );
355  }
356  Vec_IntFree( vInt2HandleOld );
357  ABC_FREE( pBinsOld );
358 // Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
359 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static int * Abc_NamStrHashFind(Abc_Nam_t *p, const char *pStr, const char *pLim)
Definition: utilNam.c:305
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static char * Abc_NamHandleToStr(Abc_Nam_t *p, int h)
Definition: utilNam.c:57
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452