void WeMesh::FreeDeletedElements() { for(auto I = Faces.begin();I != Faces.end();) { auto J = I; I++; if(J->IsDeleted()) { Faces.erase(J); } } for(auto I = Edges.begin();I != Edges.end();) { auto J = I; I++; if(J->IsDeleted()) { Edges.erase(J); } } for(auto I = Vertices.begin();I != Vertices.end();) { auto J = I; I++; if(J->IsDeleted()) { Vertices.erase(J); } } }
CWebGLProgram::~CWebGLProgram() { if (!IsDeleted() && GetContext()) { GetContext()->deleteProgram(this); } }
void Socket::ReadCallback(uint32 len) { if(IsDeleted() || !IsConnected()) return; // We have to lock here. m_readMutex.Acquire(); size_t space = readBuffer.GetSpace(); int bytes = recv(m_fd, readBuffer.GetBuffer(), space, 0); if(bytes <= 0) { m_readMutex.Release(); Disconnect(); return; } else if(bytes > 0) { //m_readByteCount += bytes; readBuffer.IncrementWritten(bytes); // call virtual onread() OnRead(); } m_BytesRecieved += bytes; m_readMutex.Release(); }
void SComm::MarkAsDeleted() { if (!g_DeletedCommList) return; // If already present in g_DeletedCommList - // do not add the second time. if (FindInDeletedCommList()) { // g_DeletedCommList currently only supports deleted items. // This assert will warn us if the situation changes. // Then the logic should change similarly to the logic // in Comm::AddWaitingComm(). OP_ASSERT(IsDeleted()); return; } #ifdef DEBUG_MH FILE *fp = fopen("c:\\klient\\msghan.txt", "a"); fprintf(fp, "[%d] SComm::MarkDeleteComm new obj: %p (status=%d)\n", comm_list_call_count, comm, COMM_WAIT_STATUS_DELETE); fclose(fp); #endif OP_ASSERT(g_SCommWaitElm_factory); SCommWaitElm *lwe = g_SCommWaitElm_factory->Allocate(); if (lwe) { lwe->Init(this, SCOMM_WAIT_STATUS_DELETE); // Add the object to the deletion queue. lwe->Into(g_DeletedCommList); if(g_comm_cleaner) g_comm_cleaner->SignalWaitElementActivity(); } }
void Object::Update( float time ) { if( IsDeleted() ) { return; } m_rotation += ( m_rotational_velocity * time ); m_position += ( m_velocity * time ); }
size_t WebGLTexture::MemoryUsage() const { if (IsDeleted()) return 0; size_t accum = 0; for (const auto& cur : mImageInfoArr) { accum += cur.MemoryUsage(); } return accum; }
int dbDatabase::PutRecord(unsigned int tbHandle, int recno, dbRecord& Record, bool f) { unsigned int j, i, r; int z; char buff[2]; ArrayMap<String, struct fieldStruct> &fs = fields[tbHandle]; if( (recno > 0) && (recno <= tables[tbHandle].numOfRecord)) { if(IsDeleted(tbHandle, recno)) return MTDB_REC_DELETED; tables[tbHandle].record = recno; } else if((recno == MTDB_TB_APP) || (recno == tables[tbHandle].numOfRecord+1)) { tables[tbHandle].numOfRecord++; tables[tbHandle].record = tables[tbHandle].numOfRecord; recno = tables[tbHandle].record; Insert(tables[tbHandle].offset + tables[tbHandle].tableHead + ((recno-1) * tables[tbHandle].recordLenght), tables[tbHandle].recordLenght); eodsp += tables[tbHandle].recordLenght; for(r=tbHandle+1; r<numOfTables; r++) { tables[r].offset += tables[tbHandle].recordLenght; } dbUpdateHead(); buff[0] = MTDB_TB_RECORD_ENABLED; lseek(fhandle, (int)tables[tbHandle].offset+tables[tbHandle].tableHead+(tables[tbHandle].recordLenght*(recno-1)), 0); write(fhandle, buff, 1); // verifico ed aggiorno la chiave primaria for(i=0; i<tables[tbHandle].numOfFields; i++) { if (_isBitSet(fs[i].flags, MTDB_FD_PRIM_KEY)) { lseek(fhandle, (int)tables[tbHandle].offset+tables[tbHandle].tableHead+(tables[tbHandle].recordLenght*(recno-1))+fs[i].prevLength+1, 0); write(fhandle, &tables[tbHandle].autoincCntr, fs[i].length); tables[tbHandle].autoincCntr++; } } // fine agg. chiave primaria tbUpdateHead(tbHandle); } else if(recno == MTDB_TB_ACT) recno = tables[tbHandle].record; else return MTDB_INV_RECNO; #ifdef _WITH_DEBUG RLOG("Put record: " + FormatInt(recno)); #endif for(j=0; j<Record.GetCount(); j++) { ArrayMap<String, struct fieldStruct> &fs = fields[tbHandle]; z = fs.Find(Record.GetName(j)); if(z >= 0) FieldPut(tbHandle, recno, z, Record[j], f); } Time t = GetSysTime(); lseek(fhandle, (int)tables[tbHandle].offset+21, 0); write(fhandle, &t, 8); tables[tbHandle].lastModifyTime = t; return MTDB_SUCCESS; }
void Player::FlushBuffer() { if( IsDeleted() || m_half_open ) { return; } while( !m_send_buffer.empty() ) { Send( m_send_buffer.front() ); m_send_buffer.pop_front(); } }
void Player::SendPacket( PacketPtr packet, bool prio ) { if( IsDeleted() ) { return; } if( !prio ) { m_send_buffer.push_back( packet ); } else { Send( packet ); } }
void CHomonym::Print(TOutputStream& stream, ECharset encoding) const { Stroka s; s = GetStrKWType(encoding); if (s.size()) s = Substitute(" (<b>$0</b>) ", s); if (IsDeleted()) s += "[deleted]"; stream << NStr::Encode(GetShortLemma(), encoding) << " "; PrintGrammems(Grammems.All(), stream, encoding); stream << s << GetLabelsString(encoding); }
size_t WebGLTexture::MemoryUsage() const { if (IsDeleted()) return 0; size_t result = 0; for(size_t face = 0; face < mFacesCount; face++) { for(size_t level = 0; level <= mMaxLevelWithCustomImages; level++) { result += ImageInfoAtFace(face, level).MemoryUsage(); } } return result; }
bool CRTF_SectionMarker::IsChanged() { if(IsDeleted()) { return false; } for(unsigned int i = 0; i < (x64_int_cast)theHdrFtrs.size(); i++) { if(theHdrFtrs[i]->IsChanged()) return true; } return false; }
bool WebGLTexture::BindTexture(TexTarget texTarget) { // silently ignore a deleted texture if (IsDeleted()) return false; if (HasEverBeenBound() && mTarget != texTarget) { mContext->ErrorInvalidOperation("bindTexture: this texture has already been bound to a different target"); return false; } mContext->SetFakeBlackStatus(WebGLContextFakeBlackStatus::Unknown); Bind(texTarget); return true; }
void Socket::Disconnect() { //if returns false it means it's already disconnected if(!m_connected.SetVal(false)) return; sLog.outDetail("Socket::Disconnect on socket %u", m_fd); // remove from mgr sSocketMgr.RemoveSocket(this); // Call virtual ondisconnect OnDisconnect(); if(!IsDeleted()) Delete(); }
void Socket::WriteCallback() { if(IsDeleted() || !IsConnected()) return; // We should already be locked at this point, so try to push everything out. int bytes_written = send(m_fd, writeBuffer.GetBufferStart(), writeBuffer.GetContiguiousBytes(), 0); if(bytes_written < 0) { // error. Disconnect(); return; } m_BytesSent += bytes_written; //RemoveWriteBufferBytes(bytes_written, false); writeBuffer.Remove(bytes_written); }
/* Validate a node. Check to see that the node is "clean" in the sense that nothing has over/underwritten it etc. */ int wxMemStruct::ValidateNode () { char * startPointer = (char *) this; if (!AssertIt ()) { if (IsDeleted ()) ErrorMsg ("Object already deleted"); else { // Can't use the error routines as we have no recognisable object. #ifndef __WXGTK__ wxLogMessage(wxT("Can't verify memory struct - all bets are off!")); #endif } return 0; } /* int i; for (i = 0; i < wxDebugContext::TotSize (requestSize ()); i++) cout << startPointer [i]; cout << endl; */ if (Marker () != MemStartCheck) ErrorMsg (); if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck) ErrorMsg (); if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, RequestSize ()) != MemEndCheck) ErrorMsg (); // Back to before the extra buffer and check that // we can still read what we originally wrote. if (Marker () != MemStartCheck || * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck || * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, RequestSize ()) != MemEndCheck) { ErrorMsg (); return 0; } return 1; }
void csArchive::UpdateDirectory () { /* Update archive directory: remove deleted entries first */ int n; for (n = dir.Length () - 1; n >= 0; n--) { ArchiveEntry *e = dir.Get (n); if (IsDeleted (e->filename)) dir.Delete (n); } del.DeleteAll (); for (n = 0; n < lazy.Length (); n++) { ArchiveEntry *e = lazy.Get (n); e->FreeBuffer (); dir.InsertSorted (e); lazy [n] = NULL; } lazy.DeleteAll (); }
bool WebGLTexture::BindTexture(TexTarget texTarget) { if (IsDeleted()) { mContext->ErrorInvalidOperation("bindTexture: Cannot bind a deleted object."); return false; } const bool isFirstBinding = !HasEverBeenBound(); if (!isFirstBinding && mTarget != texTarget) { mContext->ErrorInvalidOperation("bindTexture: This texture has already been bound" " to a different target."); return false; } mTarget = texTarget; mContext->gl->fBindTexture(mTarget.get(), mGLName); if (isFirstBinding) { mFaceCount = IsCubeMap() ? 6 : 1; gl::GLContext* gl = mContext->gl; // Thanks to the WebKit people for finding this out: GL_TEXTURE_WRAP_R // is not present in GLES 2, but is present in GL and it seems as if for // cube maps we need to set it to GL_CLAMP_TO_EDGE to get the expected // GLES behavior. // If we are WebGL 2 though, we'll want to leave it as REPEAT. const bool hasWrapR = gl->IsSupported(gl::GLFeature::texture_3D); if (IsCubeMap() && hasWrapR && !mContext->IsWebGL2()) { gl->fTexParameteri(texTarget.get(), LOCAL_GL_TEXTURE_WRAP_R, LOCAL_GL_CLAMP_TO_EDGE); } } return true; }
bool csArchive::WriteCentralDirectory (FILE *temp) { int n, count = 0; size_t cdroffs = ftell (temp); for (n = 0; n < dir.Length (); n++) { ArchiveEntry *f = dir.Get (n); if (IsDeleted (f->filename)) continue; if (!f->WriteCDFH (temp)) return false; count++; } /* endwhile */ for (n = 0; n < lazy.Length (); n++) { ArchiveEntry *f = lazy.Get (n); if (!f->WriteCDFH (temp)) return false; count++; } /* endwhile */ /* Write end-of-central-directory record */ ZIP_end_central_dir_record ecdr; memset (&ecdr, 0, sizeof (ecdr)); ecdr.num_entries_centrl_dir_ths_disk = count; ecdr.total_entries_central_dir = count; ecdr.size_central_directory = ftell (temp) - cdroffs; ecdr.offset_start_central_directory = cdroffs; ecdr.zipfile_comment_length = comment_length; if (!WriteECDR (ecdr, temp)) return false; return true; }
int dbDatabase::GetRecord(unsigned int tbHandle, int recno, dbRecord& Record) { int i, r; char buff[1]; Value v; if(recno > 0) tables[tbHandle].record = recno; else if(recno == MTDB_TB_ACT) recno = tables[tbHandle].record; else return MTDB_INV_RECNO; if(IsDeleted(tbHandle, recno)) return MTDB_REC_DELETED; Record.Reset(); for(i=0; i<tables[tbHandle].numOfFields; i++) { if((r = FieldGet(tbHandle, recno, i, v)) == MTDB_SUCCESS) { ArrayMap<String, struct fieldStruct> &fs = fields[tbHandle]; String s = fs[i].name; Record.Add(s, v); } else return r; } return MTDB_SUCCESS; }
bool WebGLTexture::IsTexture() const { return HasEverBeenBound() && !IsDeleted(); }
//======================================================================= //function : PrepareHistory //purpose : //======================================================================= void GEOMAlgo_Builder::PrepareHistory() { if(myShape.IsNull()) { return; } // Standard_Boolean bHasImage, bContainsSD; TopAbs_ShapeEnum aType; TopTools_MapOfShape aMS; TopTools_ListIteratorOfListOfShape aIt; TopTools_MapIteratorOfMapOfShape aItM; // // 1. Clearing GEOMAlgo_BuilderShape::PrepareHistory(); // // 2. myMapShape - all shapes of result with theirs sub-shapes MapShapes(myShape, myMapShape); // // 3. MS - all argument shapes with theirs sub-shapes aIt.Initialize(myShapes); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSx=aIt.Value(); MapShapes(aSx, aMS); } // // 4. Treatment aItM.Initialize(aMS); for (; aItM.More(); aItM.Next()) { const TopoDS_Shape& aSx=aItM.Key(); aType=aSx.ShapeType(); //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f // // 4.1 .myImagesResult TopTools_ListOfShape aLSx; // bHasImage=myImages.HasImage(aSx); if (!bHasImage) { if (myMapShape.Contains(aSx)) { aLSx.Append(aSx); myImagesResult.Add(aSx, aLSx); } } else { const TopTools_ListOfShape& aLSp=myImages.Image(aSx); aIt.Initialize(aLSp); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSp=aIt.Value(); if (myMapShape.Contains(aSp)) { aLSx.Append(aSp); } } myImagesResult.Add(aSx, aLSx); } // //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t // // 4.2 As it was if (!myHasDeleted) { myHasDeleted=IsDeleted(aSx);//xx } // if (!myHasGenerated || !myHasModified) { if (aType==TopAbs_EDGE || aType==TopAbs_FACE || aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f //bHasImage=myImages.HasImage(aSx); //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t if (bHasImage) { const TopTools_ListOfShape& aLSp=myImages.Image(aSx); aIt.Initialize(aLSp); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSp=aIt.Value(); // if (myMapShape.Contains(aSp)) { bContainsSD=mySameDomainShapes.Contains(aSp); // if (!myHasGenerated) { if (bContainsSD) { myHasGenerated=Standard_True; } } if (!myHasModified) { if (!bContainsSD) { myHasModified=Standard_True; } } } // if (myMapShape.Contains(aSp)) } } } } } }
// Write pending operations into ZIP archive bool csArchive::WriteZipArchive () { char temp_file[MAXPATHLEN]; FILE *temp; char buff [16 * 1024]; bool success = false; int n = 0; // Check if file is opened for reading first if (!file) return false; // Step one: Copy archive file into a temporary file, // skipping entries marked as 'deleted' strcpy (temp_file, TEMP_DIR); int tmplen = strlen (temp_file); APPEND_SLASH (temp_file, tmplen); sprintf (&temp_file[tmplen], TEMP_FILE); if ((temp = fopen (temp_file, "w+b")) == NULL) return false; /* Cannot create temporary file */ fseek (file, 0, SEEK_SET); while (fread (buff, 1, sizeof (hdr_local), file) == sizeof (hdr_local)) { size_t bytes_to_copy, bytes_to_skip; ArchiveEntry *this_file = NULL; if (memcmp (buff, hdr_local, sizeof (hdr_local)) == 0) { // local header ZIP_local_file_header lfh; if (!ReadLFH (lfh, file)) goto temp_failed; char *this_name = new char[lfh.filename_length + 1]; if (fread (this_name, 1, lfh.filename_length, file) < lfh.filename_length) { delete [] this_name; goto temp_failed; } this_name[lfh.filename_length] = 0; if (IsDeleted (this_name)) { skip_entry: bytes_to_skip = lfh.extra_field_length + lfh.csize; bytes_to_copy = 0; delete [] this_name; } else { this_file = (ArchiveEntry *) FindName (this_name); if (!this_file) /* This means we found a entry in archive which is not * present in our `dir' array: this means either the ZIP * file has changed after we read the ZIP directory, * or this is a `pure directory' entry (which we ignore * during reading). In any case, just copy it unchanged * into the output file. */ goto skip_entry; delete [] this_name; if (this_file->info.csize != lfh.csize) goto temp_failed; /* Broken archive */ this_file->ReadExtraField (file, lfh.extra_field_length); bytes_to_skip = 0; bytes_to_copy = lfh.csize; if (!this_file->WriteLFH (temp)) goto temp_failed; /* Write error */ } } else if (memcmp (buff, hdr_central, sizeof (hdr_central)) == 0) { // central directory header ZIP_central_directory_file_header cdfh; if (!ReadCDFH (cdfh, file)) goto temp_failed; bytes_to_copy = 0; bytes_to_skip = cdfh.filename_length + cdfh.extra_field_length + cdfh.file_comment_length; } else if (memcmp (buff, hdr_endcentral, sizeof (hdr_endcentral)) == 0) { // end-of-central-directory header ZIP_end_central_dir_record ecdr; char buff [ZIP_END_CENTRAL_DIR_RECORD_SIZE]; if (fread (buff, 1, ZIP_END_CENTRAL_DIR_RECORD_SIZE, file) < ZIP_END_CENTRAL_DIR_RECORD_SIZE) goto temp_failed; LoadECDR (ecdr, buff); bytes_to_copy = 0; bytes_to_skip = ecdr.zipfile_comment_length; } else { // Unknown chunk type goto temp_failed; } /* endif */ if (bytes_to_skip) fseek (file, bytes_to_skip, SEEK_CUR); while (bytes_to_copy) { size_t size; if (bytes_to_copy > sizeof (buff)) size = sizeof (buff); else size = bytes_to_copy; if ((fread (buff, 1, size, file) < size) || (fwrite (buff, 1, size, temp) < size)) goto temp_failed; bytes_to_copy -= size; } } /* endwhile */ /* Now we have to append all files that were added to archive */ for (n = 0; n < lazy.Length (); n++) { ArchiveEntry *f = lazy.Get (n); if (!f->WriteFile (temp)) goto temp_failed; /* Write error */ } /* endfor */ /* And finaly write central directory structure */ if (!WriteCentralDirectory (temp)) goto temp_failed; /* Now copy temporary file into archive. If we'll get a error in process, */ /* we're lost! I don't know for a good solution for this without wasting */ /* disk space for yet another copy of the archive :-( */ { fseek (temp, 0, SEEK_END); size_t fsize = ftell (temp); fseek (temp, 0, SEEK_SET); fclose (file); if ((file = fopen (filename, "wb")) == NULL) { file = fopen (filename, "rb"); goto temp_failed; } while (fsize) { size_t bytes_read = fread (buff, 1, sizeof (buff), temp); if (fwrite (buff, 1, bytes_read, file) < bytes_read) { /* Yuck! Keep at least temporary file */ fclose (temp); fclose (file); file = fopen (filename, "rb"); return false; } fsize -= bytes_read; } /* Hurray! We're done */ fclose (file); file = fopen (filename, "rb"); } /* Now if we are here, all operations have been successful */ UpdateDirectory (); success = true; temp_failed: fclose (temp); unlink (temp_file); return success; }
WebGLVertexArray::~WebGLVertexArray() { MOZ_ASSERT(IsDeleted()); }