AcePerl
view release on metacpan or search on metacpan
acelib/arraysub.c view on Meta::CPAN
bp += width ;
break ;
}
eol: if (!*cp)
break ;
if (*cp != '\n')
++cp ;
*cp++ = 0 ;
}
kLine = 0 ; /* reset for uNextLine() */
popLine = nlines ;
array(lines,nlines,char*) = 0 ; /* 0 terminate */
return nlines ;
}
char *uNextLine (char *text)
{
if (text != linesText)
messout ("Warning : uNextLine being called with bad context") ;
return array(lines,kLine++,char*) ;
}
char *uPopLine (char *text)
{
if (text != linesText)
messout ("Warning : uPopLine being called with bad context") ;
if (popLine)
return array(lines,--popLine,char*) ;
else return 0;
}
char **uBrokenLines (char *text, int width)
{
uLinesText (text,width) ;
return (char**)lines->base ;
}
char *uBrokenText (char *text, int width)
{
char *cp ;
uLinesText (text,width) ;
uNextLine (text) ;
while ((cp = uNextLine (text)))
*(cp-1) = '\n' ;
return arrp(textcopy,0,char) ;
}
/*************************************************************/
/* perfmeters */
int assBounce = 0, assFound = 0, assNotFound = 0, assInserted = 0, assRemoved = 0 ;
/* Associator package is for associating pairs of pointers.
Assumes that an "in" item is non-zero and non -1.
Implemented as a hash table of size 2^m.
Originally grabbed from Steve Om's sather code by Richard Durbin.
Entirelly rewritten by mieg, using bouncing by relative primes
and deletion flagging.
User has access to structure member ->n = # of pairs
*/
#define VSIZE (sizeof(void*))
#define VS5 (VSIZE/5)
#define VS7 (VSIZE/7)
#define moins_un ((void*) (-1))
#define HASH(_xin) { register long z = VS5, x = (char*)(_xin) - (char*)0 ; \
for (hash = x, x >>= 5 ; z-- ; x >>= 5) hash ^= x ; \
hash &= a->mask ; \
}
#define DELTA(_xin) { register long z = VS7, x = (char*)(_xin) - (char*)0 ; \
for (delta = x, x >>= 7 ; z-- ; x >>= 7) delta ^= x ; \
delta = (delta & a->mask) | 0x01 ; \
} /* delta odd is prime relative to 2^m */
/**************** Destruction ****************************/
static void assFinalise(void *cp)
{ Associator a = (Associator)cp;
a->magic = 0 ;
if (!finalCleanup)
{ messfree(a->in) ;
messfree(a->out);
}
}
void uAssDestroy (Associator a)
{ if (assExists(a))
messfree (a) ; /* calls assFinalise */
}
/**************** Creation *******************************/
#ifndef MEM_DEBUG
static Associator assDoCreate (int nbits, STORE_HANDLE handle)
#else
static Associator assDoCreate (int nbits, STORE_HANDLE handle,
const char *hfname, int hlineno)
#endif
{ static int nAss = 0 ;
Associator a ;
int size = 1 << nbits, /* size must be a power of 2 */
vsize = size * VSIZE ;
#ifndef MEM_DEBUG
a = (Associator) handleAlloc(assFinalise,
handle,
sizeof (struct AssStruct)) ;
a->in = (void**) messalloc (vsize) ;
a->out = (void**) messalloc (vsize) ;
#else
a = (Associator) handleAlloc_dbg(assFinalise,
handle,
sizeof (struct AssStruct),
dbgPos(hfname, hlineno, __FILE__), __LINE__) ;
a->in = (void**) messalloc_dbg(vsize,dbgPos(hfname, hlineno, __FILE__), __LINE__) ;
( run in 1.531 second using v1.01-cache-2.11-cpan-5a3173703d6 )