コード例 #1
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::enlargeArray(Memory& mem)
	{
		if(mDataLen != 0)
			resizeArray(mem, mDataLen * 2);
		else
			resizeArray(mem, 4);
	}
コード例 #2
0
void OftHeader::writeData(QIODevice *dev)
{
	DataUnit data;
	debug() << "Outgoing oft message with type" << hex << type;
	data.append<quint16>(type);
	data.append<quint64>(cookie);
	data.append<quint16>(encrypt);
	data.append<quint16>(compress);
	data.append<quint16>(totalFiles);
	data.append<quint16>(filesLeft);
	data.append<quint16>(totalParts);
	data.append<quint16>(partsLeft);
	data.append<quint32>(totalSize);
	data.append<quint32>(size);
	data.append<quint32>(modTime);
	data.append<quint32>(checksum);
	data.append<quint32>(receivedResourceForkChecksum);
	data.append<quint32>(resourceForkSize);
	data.append<quint32>(creationTime);
	data.append<quint32>(resourceForkChecksum);
	data.append<quint32>(bytesReceived);
	data.append<quint32>(receivedChecksum);
	{
		QByteArray ident = identification.toLatin1();
		resizeArray(ident, 32);
		data.append(ident);
	}
	data.append<quint8>(flags);
	data.append<quint8>(0x1C);
	data.append<quint8>(0x11);
	{
		QByteArray dummy;
		resizeArray(dummy, 69);
		data.append(dummy);
	}
	resizeArray(macFileInfo, 16);
	data.append(macFileInfo);
	data.append<quint16>(CodecUtf16Be);
	data.append<quint16>(0);
	{
		QByteArray name = utf16Codec()->fromUnicode(fileName);
		name = name.mid(2);
		if (name.size() < 64)
			resizeArray(name, 64);
		else
			name.append("\0\0");
		data.append(name);
	}
	DataUnit header;
	header.append<quint32>(0x4F465432); // Protocol version: "OFT2"
	header.append<quint16>(data.dataSize() + 6);
	header.append(data);
	dev->write(header.data());
}
コード例 #3
0
ファイル: Recorder.cpp プロジェクト: aothms/ear
void FloatBuffer::Truncate(unsigned int l) {
	if ( l == 0 ) l = 1;
	if ( l >= length ) {
		resizeArray(l);
	}
	real_length = l;
}
コード例 #4
0
ファイル: AS_BAT_Outputs.C プロジェクト: ondovb/canu
//  Massage the Unitig into a MultiAlignT (also used in SplitChunks_CGW.c)
void
unitigToTig(tgTig       *tig,
            uint32       tigid,
            Unitig      *utg) {

  tig->clear();

  tig->_tigID           = tigid;
  tig->_coverageStat    = 1.0;  //  Default to just barely unique
  tig->_microhetProb    = 1.0;  //  Default to 100% probability of unique

  tig->_suggestRepeat   = false;
  tig->_suggestUnique   = false;
  tig->_suggestCircular = false;
  tig->_suggestHaploid  = false;

  tig->_layoutLen       = utg->getLength();

  resizeArray(tig->_children, tig->_childrenLen, tig->_childrenMax, utg->ufpath.size(), resizeArray_doNothing);

  for (uint32 fi=0; fi<utg->ufpath.size(); fi++) {
    ufNode        *frg = &utg->ufpath[fi];
    tgPosition    *pos =  tig->addChild();

    pos->set(frg->ident, frg->parent, frg->ahang, frg->bhang, frg->position.bgn, frg->position.end);
  }

  //fprintf(stderr, "unitigToTig()--  tig %u has %u children\n", tig->_tigID, tig->_childrenLen);
}
コード例 #5
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::append(Memory& mem, GCObject** srcPtr, size_t srcLen)
	{
		if(mDataLen < (mSize + srcLen))
			resizeArray(mem, largerPow2(mSize + srcLen));

		if(mStart <= mEnd)
		{
			// empty space may be split over the end
			size_t endLen = mDataLen - mEnd;

			if(endLen >= srcLen)
			{
				memcpy(mDataPtr + mEnd, srcPtr, srcLen * sizeof(GCObject*));
				mEnd += srcLen;
			}
			else
			{
				memcpy(mDataPtr + mEnd, srcPtr, endLen * sizeof(GCObject*));
				size_t beginLen = srcLen - endLen;
				memcpy(mDataPtr, srcPtr + endLen, beginLen * sizeof(GCObject*));
				mEnd = beginLen;
			}
		}
		else
		{
			memcpy(mDataPtr + mEnd, srcPtr, srcLen * sizeof(GCObject*));
			mEnd += srcLen;
		}

		if(mEnd == mDataLen)
			mEnd = 0;

		mSize += srcLen;
	}
コード例 #6
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::prealloc(Memory& mem, size_t size)
	{
		if(size <= mDataLen)
			return;
		else if(size > 4)
			resizeArray(mem, largerPow2(size));
	}
コード例 #7
0
ファイル: Recorder.cpp プロジェクト: aothms/ear
float& FloatBuffer::operator[] (const unsigned int i) {
	if ( i >= length ) {
		resizeArray(i+INCREMENTAL_BUFFER_SIZE);
	}
	if ( i > real_length ) real_length = i;
	if ( i < first_sample ) first_sample = i;
	return data[i];
}
コード例 #8
0
ファイル: vector.c プロジェクト: kpespinosa/CMSC21
void addElement(int element)
{
	if (count > (size / 2))
	{
		ar = resizeArray(ENLARGE_FACTOR);
	}
	ar[count] = element;
	count++;
}
コード例 #9
0
void
abAbacus::refreshColumns(void) {

  //fprintf(stderr, "abAbacus::refreshColumns()--\n");

  //  Given that _firstColumn is a valid column, walk to the start of the column list.

  while (_firstColumn->_prevColumn != NULL)
    _firstColumn = _firstColumn->_prevColumn;

  //  Number the columns, so we can make sure the _columns array has enough space.  Probably not
  //  needed to be done first, but avoids having the resize call in the next loop.

  uint32 cn = 0;

  for (abColumn *column = _firstColumn; column; column = column->next())
    column->_columnPosition = cn++;  //  Position of the column in the gapped consensus.

  //  Fake out resizeArray so it will work on three arrays.

  uint32  cm = _columnsMax;

  resizeArray(_columns,  0, cm, cn+1, resizeArray_doNothing);  cm = _columnsMax;
  resizeArray(_cnsBases, 0, cm, cn+1, resizeArray_doNothing);  cm = _columnsMax;
  resizeArray(_cnsQuals, 0, cm, cn+1, resizeArray_doNothing);  _columnsMax = cm;

  //  Build the list of columns and update consensus and quals while we're there.

  _columnsLen = 0;

  for (abColumn *column = _firstColumn; column; column = column->next()) {
    _columns [_columnsLen] = column;
    _cnsBases[_columnsLen] = column->baseCall();
    _cnsQuals[_columnsLen] = column->baseQual();
    _columnsLen++;
  }

  _cnsBases[_columnsLen] = 0;
  _cnsQuals[_columnsLen] = 0;  //  Not actually zero terminated.

  //for (abColumn *column = _firstColumn; column; column = column->next())
  //  fprintf(stderr, "refreshColumns()--  column %p is at position %d\n",
  //          column, column->position());
}
コード例 #10
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::minimize(Memory& mem)
	{
		if(mSize == 0)
			clear(mem);
		else
		{
			size_t size = largerPow2(mSize);
			resizeArray(mem, size < 4 ? 4 : size);
		}
	}
コード例 #11
0
ファイル: Recorder.cpp プロジェクト: aothms/ear
void FloatBuffer::Read(const std::string& fn) {
  std::ifstream f(fn.c_str(),std::ios_base::binary);
	f.seekg(0,std::ios_base::end);
  std::streamsize stream_size = f.tellg();
	f.seekg(0,std::ios_base::beg);
	resizeArray(stream_size/4);
  f.read((char*)data,stream_size);
  first_sample = 0;
  real_length = stream_size / 4;
}
コード例 #12
0
ファイル: list.cpp プロジェクト: anuruddhah/DSALib
	void ArrayList<T>::insert(int pos, const T& val)
	{
		if (size == fullSize)
			resizeArray();
		for (int i = size; i > pos; i--)
		{
			ar[i] = ar[i - 1];
		}
		ar[pos] = val;
		size++;
	}
コード例 #13
0
ファイル: syntax.c プロジェクト: honza889/IFJ12
void addExpressionToExpressionList( ExpressionList* el, Expression* expression )
{
    if(el->expressions==NULL){
        el->count=1;
        el->expressions = newArray( Statement, el->count );
        el->expressions[0] = *expression;
    }else{
        el->count++;
        el->expressions = resizeArray( el->expressions, Expression, el->count );
        el->expressions[el->count-1] = *expression;
    }
}
コード例 #14
0
ファイル: syntax.c プロジェクト: honza889/IFJ12
void addStatementToStatementList( StatementList* sl, Statement* statement )
{
    if(sl->item==NULL){
        sl->count=1;
        sl->item = newArray( Statement, sl->count );
        sl->item[0] = *statement;
    }else{
        sl->count++;
        sl->item = resizeArray( sl->item, Statement, sl->count );
        sl->item[sl->count-1] = *statement;
    }
}
コード例 #15
0
ファイル: syntax.c プロジェクト: honza889/IFJ12
int getFunctionId( SyntaxContext* ctx, RCString* name )
{
    int oldCount = ctx->globalSymbols->count;
    int id = getSymbol( *name, ctx->globalSymbols, NULL );
    bool newFunction = oldCount < ctx->globalSymbols->count;
    if( newFunction )
    {
        ctx->functions = resizeArray( ctx->functions, Value, ctx->globalSymbols->count );
        ctx->functions[ -id-1 ] = newValueUndefined();
    }
    return id;
}
コード例 #16
0
ファイル: parsexp.c プロジェクト: honza889/IFJ12
/** Prida polozku do zasobniku za nejvrchnejsi terminal (jen pro zavorky, bez uvolnovani!) */
void addToAfterTermExpStack(ExpStack* stack, ExpItem item){
    if(stack->count==stack->allocated){
        stack->allocated += 8;
        stack->array = resizeArray( stack->array, ExpItem, stack->allocated );
    }
    for( int i = stack->count ; i > (stack->termIndex+1) ; i-- ){
        stack->array[i] = stack->array[i-1];
    }
    stack->array[stack->termIndex+1] = item;
    if(item.type==term){
        stack->termIndex = stack->termIndex+1;
    }
    stack->count++; // zvyseni poctu polozek
}
コード例 #17
0
ファイル: VertexList.cpp プロジェクト: SylerWang/FunFashion
void VertexList::requestCapacity(int count)
{
	if (m_capacity < count)
	{
		m_capacity = count;

		const Shader* shader = m_material->shader();
		resizeArray((void**)&m_positions, m_count * 3, m_capacity * 3, sizeof(GLfloat), shader->isAttributeRequired(ePVRTPFX_UsPOSITION));
		resizeArray((void**)&m_normals, m_count * 3, m_capacity * 3, sizeof(GLfloat), shader->isAttributeRequired(ePVRTPFX_UsNORMAL));
		resizeArray((void**)&m_tangents, m_count * 3, m_capacity * 3, sizeof(GLfloat), shader->isAttributeRequired(ePVRTPFX_UsTANGENT));
		resizeArray((void**)&m_binormals, m_count * 3, m_capacity * 3, sizeof(GLfloat), shader->isAttributeRequired(ePVRTPFX_UsBINORMAL));
		resizeArray((void**)&m_uvs, m_count * 2, m_capacity * 2, sizeof(GLfloat), shader->isAttributeRequired(ePVRTPFX_UsUV));

		resizeArray((void**)&m_vertexColors, m_count * 4, m_capacity * 4, sizeof(GLubyte), shader->isAttributeRequired(ePVRTPFX_UsVERTEXCOLOR));
		resizeArray((void**)&m_boneIndices, m_count, m_capacity, sizeof(GLubyte), shader->isAttributeRequired(ePVRTPFX_UsBONEINDEX));
		resizeArray((void**)&m_boneWeights, m_count, m_capacity, sizeof(GLubyte), shader->isAttributeRequired(ePVRTPFX_UsBONEWEIGHT));
	}
}
コード例 #18
0
/**************************************************
 * This function opens the file and reads each    *
 * line into the buildArray function. It then     *
 * calls the rest of the functions to sort the    *
 * array and build the balanced binary tree.      *
 * EXIT 2 for file input error                    *
 * EXIT 1 for memory error                        *
 **************************************************/
void initialize(char *filename)
{
    FILE *fp;
    char buffer[21], **names;
    int count = 0, *count_ptr = &count, size = 2, *size_ptr = &size;
    BNODE* root;

    if ((fp = fopen(filename, "r")) == NULL)
    {
        printf("Error: Filename does not exist\n");
        exit(2);
    }
    
    if ((names = malloc(2 * sizeof(char*))) == NULL)
    {
        printf("Error: Unable to allocate memory\n");
        exit(1);
    }

    while (fgets(buffer, sizeof(buffer), fp) != NULL)
    {
        /* Double the size of the array after it is full */
        if (count == size)
            names = resizeArray(names, size_ptr);

        names = buildArray(names, buffer, count_ptr);
    }

    fclose(fp);

    names = sortArray(names, count_ptr);

    root = buildTree(names, 0, count-1);

    printf("\n preorder: ");
    preorder(root);
    printf("\n\n");

    printf("  inorder: ");
    inorder(root);
    printf("\n\n");

    printf("postorder: ");
    postorder(root);
    printf("\n");
}
コード例 #19
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::append(Memory& mem, Deque& other)
	{
		if(other.length() == 0)
			return;

		if(mDataLen < (mSize + other.length()))
			resizeArray(mem, largerPow2(mSize + other.length()));

		GCObject** startPtr = other.mDataPtr + other.mStart;

		if(other.mStart >= other.mEnd)
		{
			size_t startLen = (other.mDataPtr + other.mDataLen) - startPtr;
			size_t restLen = other.length() - startLen;
			append(mem, startPtr, startLen);
			append(mem, other.mDataPtr, restLen);
		}
		else
			append(mem, startPtr, other.length());
	}
コード例 #20
0
ファイル: standard.c プロジェクト: cmenegusWHAT/emojicode
static Something systemSystem(Thread *thread) {
    char *command = stringToChar(stackGetVariable(0, thread).object->value);
    FILE *f = popen(command, "r");
    free(command);
    
    if (!f) {
        return NOTHINGNESS;
    }
    
    size_t bufferUsedSize = 0;
    int bufferSize = 50;
    Object *buffer = newArray(bufferSize);
    
    while (fgets((char *)buffer->value + bufferUsedSize, bufferSize - (int)bufferUsedSize, f) != NULL) {
        bufferUsedSize = strlen(buffer->value);
        
        if (bufferSize - bufferUsedSize < 2) {
            bufferSize *= 2;
            buffer = resizeArray(buffer, bufferSize);
        }
    }
    
    bufferUsedSize = strlen(buffer->value);
    
    EmojicodeInteger len = u8_strlen_l(buffer->value, bufferUsedSize);
    
    Object *so = newObject(CL_STRING);
    stackSetVariable(0, somethingObject(so), thread);
    String *string = so->value;
    string->length = len;
    
    Object *chars = newArray(len * sizeof(EmojicodeChar));
    string = stackGetVariable(0, thread).object->value;
    string->characters = chars;
    
    u8_toucs(characters(string), len, buffer->value, bufferUsedSize);
    
    return stackGetVariable(0, thread);
}
コード例 #21
0
ファイル: parsexp.c プロジェクト: honza889/IFJ12
/** Prida polozku do vrcholu zasobniku */
void addToExpStack(ExpStack* stack, ExpItem item){
    // zvetseni zasobniku, neni-li dostatecne velky
    if(stack->count==stack->allocated){
        stack->allocated += 8;
        stack->array = resizeArray( stack->array, ExpItem, stack->allocated );
    }
    // pridani polozky
    stack->array[stack->count] = item;
    if(item.type==term){
        stack->termIndex = stack->count; // nyni je nevrcholovejsim terminalem
        
        // kopirovani hodnot pro potreby pozdejsiho uvolnovani pameti
        if( item.val.term.type == tokId )
        {
            stack->array[stack->count].val.term.data.id = copyRCString( &item.val.term.data.id );
        }
        if( item.val.term.type == tokLiteral )
        {
            stack->array[stack->count].val.term.data.val = copyValue( &item.val.term.data.val );
        }
    }
    stack->count++; // zvyseni poctu polozek
}
コード例 #22
0
ファイル: standard.cpp プロジェクト: orochisam/emojicode
static void systemSystem(Thread *thread) {
    FILE *f = popen(stringToCString(thread->variable(0).object), "r");

    if (f == nullptr) {
        thread->returnNothingnessFromFunction();
        return;
    }

    size_t bufferUsedSize = 0;
    int bufferSize = 50;
    auto buffer = thread->retain(newArray(bufferSize));

    while (fgets(buffer->val<char>() + bufferUsedSize, bufferSize - (int)bufferUsedSize, f) != nullptr) {
        bufferUsedSize = strlen(buffer->val<char>());

        if (bufferSize - bufferUsedSize < 2) {
            bufferSize *= 2;
            buffer = resizeArray(buffer.unretainedPointer(), bufferSize, thread);
        }
    }

    bufferUsedSize = strlen(buffer->val<char>());

    EmojicodeInteger len = u8_strlen_l(buffer->val<char>(), bufferUsedSize);

    auto so = thread->retain(newObject(CL_STRING));
    auto *string = so->val<String>();
    string->length = len;

    Object *chars = newArray(len * sizeof(EmojicodeChar));
    string = so->val<String>();
    string->charactersObject = chars;

    u8_toucs(string->characters(), len, buffer->val<char>(), bufferUsedSize);
    thread->release(2);
    thread->returnFromFunction(so.unretainedPointer());
}
コード例 #23
0
ファイル: spanning-trees.c プロジェクト: pocketzeroes/proekt
pair*pushback(pair *array, int *size, pair value) {
  pair *output = resizeArray(array, pair, *size + 1);
  output[(*size)++] = value;
  return output;
}
コード例 #24
0
ファイル: dynamicarray.c プロジェクト: WildAndrewLee/Espresso
void insertArrayValue(void* val, array arr){
	if(arr->length >= arr->size - 1)
		resizeArray(arr);

	arr->values[arr->length++] = val;
}
コード例 #25
0
//  Add string  s  as an extra hash table string and return
//  a single reference to the beginning of it.
static
String_Ref_t
Add_Extra_Hash_String(const char *s) {
  String_Ref_t  ref = 0;
  String_Ref_t  sub = 0;

  int  len;

  uint32 new_len = Used_Data_Len + G.Kmer_Len;

  if (Extra_String_Subcount < MAX_EXTRA_SUBCOUNT) {
    sub = String_Ct + Extra_String_Ct - 1;

  } else {
    sub = String_Ct + Extra_String_Ct;

    if (sub >= String_Start_Size) {
      uint64  n = max(sub * 1.1, String_Start_Size * 1.5);

      //fprintf(stderr, "REALLOC String_Start from "F_U64" to "F_U64"\n", String_Start_Size, n);
      resizeArray(String_Start, String_Start_Size, String_Start_Size, n);
    }

    String_Start[sub] = Used_Data_Len;

    Extra_String_Ct++;
    Extra_String_Subcount = 0;
    new_len++;
  }

  if (new_len >= Extra_Data_Len) {
    uint64  n = max(new_len * 1.1, Extra_Data_Len * 1.5);

    //fprintf(stderr, "REALLOC basesData from "F_U64" to "F_U64"\n", Extra_Data_Len, n);
    resizeArray(basesData, Extra_Data_Len, Extra_Data_Len, n);
  }

  strncpy(basesData + String_Start[sub] + G.Kmer_Len * Extra_String_Subcount, s, G.Kmer_Len + 1);

  Used_Data_Len = new_len;

  setStringRefStringNum(ref, sub);

  if (sub > MAX_STRING_NUM) {
    fprintf(stderr, "Too many skip kmer strings for hash table.\n");
    fprintf(stderr, "Try skipping hopeless check (-z option)\n");
    fprintf(stderr, "Exiting\n");
    exit (1);
  }

  setStringRefOffset(ref, (String_Ref_t)Extra_String_Subcount * (String_Ref_t)G.Kmer_Len);

  assert(Extra_String_Subcount * G.Kmer_Len < OFFSET_MASK);

  setStringRefLast(ref,  (uint64)1);
  setStringRefEmpty(ref, TRUELY_ONE);

  Extra_String_Subcount++;

  return(ref);
}
コード例 #26
0
string *pushback(string *array, int *size, string value) {
    string *output = resizeArray(array, string, *size + 1);
    output[(*size)++] = value;
    return output;
}
コード例 #27
0
ファイル: water-bottles.c プロジェクト: pocketzeroes/proekt
ll *pushback(ll *array, int *size, ll value) {
    ll *output = resizeArray(array, ll, *size + 1);
    output[(*size)++] = value;
    return output;
}
コード例 #28
0
ファイル: AS_BAT_Outputs.C プロジェクト: swang8/canu
//  Massage the Unitig into a MultiAlignT (also used in SplitChunks_CGW.c)
void
unitigToTig(tgTig       *tig,
            uint32       tigid,
            Unitig      *utg) {

  tig->clear();

  tig->_tigID           = tigid;
  utg->_tigID           = tigid;

  tig->_coverageStat    = 1.0;  //  Default to just barely unique
  tig->_microhetProb    = 1.0;  //  Default to 100% probability of unique

  if      (utg->_isUnassembled == true)
    tig->_class = tgTig_unassembled;

  else if (utg->_isBubble == true)
    tig->_class = tgTig_bubble;

  else
    tig->_class = tgTig_contig;

  tig->_suggestRepeat   = (utg->_isRepeat   == true);
  tig->_suggestCircular = (utg->_isCircular == true);

  tig->_layoutLen       = utg->getLength();

  resizeArray(tig->_children, tig->_childrenLen, tig->_childrenMax, utg->ufpath.size(), resizeArray_doNothing);

  map<uint32,bool>  forward;
  map<uint32,bool>  allreads;

  //  Just for stats, build a map fo the reads in the unitig.

  for (uint32 ti=0; ti<utg->ufpath.size(); ti++)
    allreads[utg->ufpath[ti].ident] = true;

  //  Process all reads.

  for (uint32 ti=0; ti<utg->ufpath.size(); ti++) {
    ufNode        *frg   = &utg->ufpath[ti];

    //  Remember that we've placed this read, and if it was forward or reverse.
    forward[frg->ident] = (frg->position.bgn < frg->position.end);

    //  If the first read, just dump it in the unitig with no parent.
    if (ti == 0) {
      tig->addChild()->set(frg->ident, 0, 0, 0, frg->position.bgn, frg->position.end);
      continue;
    }

#if 0
    //  Otherwise, find the thickest overlap to any read already placed in the unitig.

    uint32         olapsLen = 0;
    BAToverlap    *olaps = OC->getOverlaps(frg->ident, AS_MAX_EVALUE, olapsLen);

    uint32         tt     = UINT32_MAX;
    uint32         ttLen  = 0;
    double         ttErr  = DBL_MAX;

    int32          ah     = 0;
    int32          bh     = 0;

    uint32         notPresent = 0;  //  Potential parent isn't in the unitig
    uint32         notPlaced  = 0;  //  Potential parent isn't placed yet
    uint32         negHang    = 0;  //  Potential parent has a negative hang to a placed read
    uint32         goodOlap   = 0;

    for (uint32 oo=0; oo<olapsLen; oo++) {

      if (allreads.count(olaps[oo].b_iid) == 0) {
        notPresent++;
        continue;
      }

      if (forward.count(olaps[oo].b_iid) == 0) {       //  Potential parent not placed yet
        notPlaced++;
        continue;
      }

      uint32  l = FI->overlapLength(olaps[oo].a_iid, olaps[oo].b_iid, olaps[oo].a_hang, olaps[oo].b_hang);

      //  Compute the hangs, so we can ignore those that would place this read before the parent.
      //  This is a flaw somewhere in bogart, and should be caught and fixed earlier.

      //  Consensus is expecting the have the hangs for the parent read, not this read, and some
      //  fiddling is needed to flip the overlap for this:
      //    First, swap the reads so it's b-vs-a.
      //    Then, flip the overlap if the b read is in the unitig flipped.

      int32 ah = (olaps[oo].flipped == false) ? (-olaps[oo].a_hang) : (olaps[oo].b_hang);
      int32 bh = (olaps[oo].flipped == false) ? (-olaps[oo].b_hang) : (olaps[oo].a_hang);

      if (forward[olaps[oo].b_iid] == false) {
        swap(ah, bh);
        ah = -ah;
        bh = -bh;
      }

      //  If the ahang is negative, we flubbed up somewhere, and want to place this read before
      //  the parent (even though positions say to place it after, because we sorted by position).

      if (ah < 0) {
        //fprintf(stderr, "ERROR: read %u in tig %u has negative ahang from parent read %u, ejected.\n",
        //        frg->ident, ti, olaps[oo].b_iid);
        negHang++;
        continue;
      }

      //  The overlap is good.  Count it as such.

      goodOlap++;

      //  If the overlap is worse than the one we already have, we don't care.

      if ((l < ttLen) ||                  //  Too short
          (ttErr < olaps[oo].erate)) {    //  Too noisy
        continue;
      }

      tt    = oo;
      ttLen = l;
      ttErr = olaps[oo].erate;
    }

    //  If no thickest overlap, we screwed up somewhere.  Complain and eject the read.

    if (tt == UINT32_MAX) {
      fprintf(stderr, "ERROR: read %u in tig %u has no overlap to any previous read, ejected.  %u overlaps total.  %u negative hang.  %u to read not in tig.  %u to read later in tig.  %u good overlaps.\n",
              frg->ident, tig->tigID(), olapsLen, negHang, notPresent, notPlaced, goodOlap);
      continue;
    }

    tig->addChild()->set(frg->ident, olaps[tt].b_iid, ah, bh, frg->position.bgn, frg->position.end);
#else
    tig->addChild()->set(frg->ident, 0, 0, 0, frg->position.bgn, frg->position.end);
#endif
  }

  //fprintf(stderr, "unitigToTig()--  tig %u has %u children\n", tig->_tigID, tig->_childrenLen);
}