fut_p fut_free_futH (KpHandle_t futHandle) { fut_p fut; fut = (fut_p) lockBuffer(futHandle); if (IS_FUT(fut)) { /* free id string if exists */ /* fut_free_idstr (fut->idstr); */ /* free shared input tables */ fut_free_itbl_list_p (fut->itbl, fut->itblHandle); /* free channels */ fut_free_chan_list_p (fut->chan, fut->chanHandle); /* free fut_t structure itself */ fut->magic = 0; freeBufferPtr ((KpGenericPtr_t)fut); } return ((fut_p)NULL); }
/* fut_free_gtbl_p This function is passed a fut_gtbl_t pointer and handle. If the ref count is zero, the table and the fut_gtbl_t is freed. Otherwise the ref count is decremented and the lock state of the fut_gtbl_t is returned to it's state on entry. */ static void fut_free_gtbl_p ( fut_gtbl_p gtblP, KpHandle_t gtblHdl) { fut_gtbl_p gtbl = gtblP; if (gtblHdl == NULL) { return; } if (gtbl == NULL) { /* gtbl is unlocked on entry */ gtbl = lockBuffer(gtblHdl); } if (IS_GTBL(gtbl)) { if (gtbl->ref == 0) { fut_free_gtbl(gtbl); /* last reference being freed */ } else { if (gtbl->ref > 0) { /* still other references, leave in original lock state */ gtbl->ref--; if (gtblP == NULL) { unlockBuffer(gtblHdl); } } } } }
/* fut_free_chan_list_p For each channel, This functions frees all input tables, the output table and the grid table. It then frees the actual fut_chan_t memory. */ static void fut_free_chan_list_p ( fut_chan_p FAR * chan_list, KpHandle_t FAR * chanHdl_list) { KpInt32_t i; fut_chan_p chan; if ( (chan_list == NULL) || ( chanHdl_list == NULL) ) return; for ( i=0; i<FUT_NOCHAN; i++ ) { chan = chan_list[i]; if (chan == NULL) { /* chan is unlocked on entry */ chan = lockBuffer(chanHdl_list[i]); } if (IS_CHAN(chan)) { fut_free_itbl_list_p (chan->itbl, chan->itblHandle); /* free input tables */ fut_free_otbl_p (chan->otbl, chan->otblHandle); /* free output table */ fut_free_gtbl_p (chan->gtbl, chan->gtblHandle); /* free grid table */ /* free fut_chan_t structure itself */ chan->magic = 0; freeBufferPtr ((KpGenericPtr_t)chan); chan_list[i] = FUT_NULL_CHAN; } } }
/* fut_free_otbl_p This function is passed a fut_otbl_t pointer and handle. If the ref count is zero, the table and the fut_otbl_t is freed. Otherwise the ref count is decremented and the lock state of the fut_otbl_t is returned to it's state on entry. */ static void fut_free_otbl_p ( fut_otbl_p otblPtr, KpHandle_t otblHdl) { fut_otbl_p otbl = otblPtr; if (otblHdl == NULL) { return; } if (otbl == NULL) { /* otbl is unlocked on entry */ otbl = lockBuffer(otblHdl); } if (IS_OTBL(otbl)) { if (otbl->ref == 0) { /* last reference being freed */ freeBuffer(otbl->tblHandle); otbl->magic = 0; freeBufferPtr ((KpGenericPtr_t)otbl); } else { if (otbl->ref > 0) { /* still other references */ otbl->ref--; /* leave in original lock state */ if (otblPtr == NULL) { unlockBuffer(otblHdl); } } } } }
status_t String8::appendFormatV(const char* fmt, va_list args) { int result = NO_ERROR; #ifndef _MSC_VER va_list o; va_copy(o, args); #endif int n = vsnprintf(NULL, 0, fmt, args); if (n != 0) { size_t oldLength = length(); char* buf = lockBuffer(oldLength + n); if (buf) { #ifdef _MSC_VER vsnprintf(buf + oldLength, n + 1, fmt, args); #else vsnprintf(buf + oldLength, n + 1, fmt, o); #endif } else { result = NO_MEMORY; } } #ifndef _MSC_VER va_end(o); #endif return result; }
/*-------------------------------------------------------------------- * DESCRIPTION * Delete a profile. If there is a file associated with the profile, * it is also deleted. * * AUTHOR * lsh & mlb * * DATE CREATED * May 4, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileDelete ( SpProfile_t FAR *Profile) { KpChar_t *fileName; SpProfileData_t FAR *ProfileData; KpFileProps_t Props; /* convert profile handle to data pointer */ ProfileData = SpProfileLock (*Profile); if (NULL == ProfileData) return SpStatBadProfile; /* lock FileName handle and return ptr */ fileName = (char *) lockBuffer (ProfileData->FileName); #if defined (KPMAC) /* Convert SpIOFileChar_t to KpFileProps_t */ SpCvrtSpFileProps (&(ProfileData->Props), &Props); #endif /* delete associated file name */ if (NULL != fileName) KpFileDelete (fileName, &Props); /* unlock handles */ unlockBuffer (ProfileData->FileName); SpProfileUnlock (*Profile); return SpProfileFree (Profile); }
/* fut_free_itbl_list_p This function is passed a list of fut_itbl_t pointers and handles. If the ref count is zero, the table and the fut_itbl_t is freed. Otherwise the ref count is decremented and the lock state of the fut_itbl_t is returned to it's state on entry. */ static void fut_free_itbl_list_p ( fut_itbl_p FAR * itbl_list, KpHandle_t FAR * itblHdl_list) { KpInt32_t i; fut_itbl_p itbl; if ((itbl_list == NULL) || (itblHdl_list == NULL)) { return; } for (i = 0; i < FUT_NICHAN; i++) { itbl = itbl_list[i]; if (itbl == NULL) { itbl = lockBuffer (itblHdl_list[i]); } if (IS_ITBL(itbl)) { if (itbl->ref == 0) { fut_free_itbl (itbl); /* last reference being freed */ itbl_list[i] = NULL; itblHdl_list[i] = NULL; } else { if ( itbl->ref > 0 ) { /* still other references */ itbl->ref--; if (itbl_list[i] == NULL) { /* leave in original lock state */ unlockBuffer(itblHdl_list[i]); } } } } } }
/* initialize a PT for export * lock and return pointers to the header and fut * make the tables for the specified export format */ PTErr_t initExport ( KpHandle_t PTHdr, KpHandle_t PTData, PTType_t format, fut_hdr_p FAR* futHdrP, fut_p FAR* futP) { PTErr_t errnum = KCP_SUCCESS; fut_p fut; fut_hdr_p futHdr; KpInt32_t status; /* get fut pointer */ fut = fut_lock_fut ((KpHandle_t)PTData); if ( ! IS_FUT(fut)) { errnum = KCP_PTERR_2; goto GetOut; } /* get header pointer of checked in PT */ futHdr = (fut_hdr_p) lockBuffer (PTHdr); if (futHdr == NULL) { errnum = KCP_MEM_LOCK_ERR; goto GetOut; } if (format == PTTYPE_FUTF) { /* make fixed tables */ status = makeFutTblDat (fut); if (status != 1) { fut_free_tbldat (fut); errnum = KCP_INCON_PT; } } else { status = makeMftTblDat (fut); if (status != 1) { fut_free_mftdat (fut); errnum = KCP_INCON_PT; } } GetOut: if (errnum == KCP_SUCCESS) { *futP = fut; /* return pointers to caller */ *futHdrP = futHdr; } else { (void) unlockPT (PTHdr, fut); *futP = NULL; *futHdrP = NULL; } return errnum; }
void DepthBuffer32::Clear( boost::uint32_t value ) { boost::uint32_t* bufferPtr = NULL; if( lockBuffer( bufferPtr ) ) { // Loop unrolling via Duff's device // http://en.wikipedia.org/wiki/Duff's_device duff_copy8( value, bufferPtr, getSize() ); unlockBuffer(); } }
void String8::setPathName(const char* name, size_t len) { char* buf = lockBuffer(len); memcpy(buf, name, len); // remove trailing path separator, if present if (len > 0 && buf[len - 1] == OS_PATH_SEPARATOR) len--; buf[len] = '\0'; unlockBuffer(len); }
/* TpWriteHdr writes the header of a fut to an external memory block. */ PTErr_t TpWriteHdr( KpFd_p fd, PTType_t format, KpHandle_t PTHdr, KpInt32_t attrSize) { PTErr_t errnum = KCP_SUCCESS; fut_hdr_p futHdr; switch (format) { case PTTYPE_FUTF: /* get buffer pointer */ futHdr = (fut_hdr_p)lockBuffer (PTHdr); if (futHdr == NULL) { errnum = KCP_MEM_LOCK_ERR; return errnum; } futHdr->idstr_len = attrSize; /* insert size of attributes */ if (fut_write_hdr (fd, futHdr) == 0) { /* and write out the header */ errnum = KCP_PT_HDR_WRITE_ERR; } if ( ! unlockBuffer (PTHdr)) { errnum = KCP_MEM_UNLOCK_ERR; } break; case PTTYPE_MFT1: case PTTYPE_MFT2: case PTTYPE_MFT2_VER_0: errnum = KCP_SUCCESS; break; case PTTYPE_MAB1: case PTTYPE_MAB2: case PTTYPE_MBA1: case PTTYPE_MBA2: errnum = KCP_SUCCESS; break; default: errnum = KCP_INVAL_PTTYPE; break; } return errnum; }
status_t String8::appendFormatV(const char* fmt, va_list args) { int result = NO_ERROR; int n = vsnprintf(NULL, 0, fmt, args); if (n != 0) { size_t oldLength = length(); char* buf = lockBuffer(oldLength + n); if (buf) { vsnprintf(buf + oldLength, n + 1, fmt, args); } else { result = NO_MEMORY; } } return result; }
String8& String8::convertToResPath() { #if OS_PATH_SEPARATOR != RES_PATH_SEPARATOR size_t len = length(); if (len > 0) { char * buf = lockBuffer(len); for (char * end = buf + len; buf < end; ++buf) { if (*buf == OS_PATH_SEPARATOR) *buf = RES_PATH_SEPARATOR; } unlockBuffer(len); } #endif return *this; }
KpGenericPtr_t FAR reallocBufferPtrPrv(KpGenericPtr_t fp, KpInt32_t numBytes) { KpHandle_t h; /* initialize it in case of error */ KpGenericPtr_t p = (KpGenericPtr_t) NULL; KpInt32_t oldNumBytes; if (fp != NULL) { /* get size of old buffer */ oldNumBytes = getPtrSize(fp); if (numBytes >= 0) { /* get memory */ h = allocBufferHandle (numBytes); if (h != NULL) { /* lock it down */ p = lockBuffer (h); if (p == NULL) { freeBuffer (h); } else { /* make sure sizes make sense */ if (oldNumBytes <= numBytes) { /* copy old contents */ memmove(p, fp, oldNumBytes); } /* free old buffer */ freeBufferPtr(fp); } } } } return p; }
/*-------------------------------------------------------------------- * DESCRIPTION * Convert Profile handle to pointer to locked profile data. * * AUTHOR * lsh * * DATE CREATED * September 20, 1993 *------------------------------------------------------------------*/ SpProfileData_t FAR *SpProfileLock (SpProfile_t Profile) { SpProfileData_t FAR *ProfileData; ProfileData = lockBuffer ((KcmHandle) Profile); if (NULL != ProfileData) { #if defined(KPMAC) /* increment the lock counter */ ProfileData->LockCount++; #endif if (SpProfileDataSig != ProfileData->Signature) { unlockBuffer ((KcmHandle) Profile); return NULL; } } return ProfileData; }
/*-------------------------------------------------------------------- * DESCRIPTION * Iterate over all the tags in a profile. Call user supplied * function with the Id of each tag. * * AUTHOR * lsh * * DATE CREATED * July 7, 1994 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpTagIter ( SpProfile_t Profile, SpTagIter_t TagIterFunc, void FAR *Data) { KpInt32_t index; SpProfileData_t FAR *ProfileData; SpTagDirEntry_t FAR *tagArray; SpStatus_t Status; /* convert profile handle to pointer to locked memory */ ProfileData = SpProfileLock (Profile); if (NULL == ProfileData) return SpStatBadProfile; Status = SpDoIter ( TagIterFunc, SpIterInit, NULL, 0, Data); /* Check if Profile found via Search function */ if (ProfileData->TagArray == NULL) /* If so, it needs the Tag Array Loaded */ SpProfilePopTagArray(ProfileData); for (index = 0; (index < ProfileData->TotalCount) && (Status == SpStatSuccess); index++) { /* User Callback Function could unlock since the Profile is available, so lock before calling */ /* lock TagArray handle and return ptr */ tagArray = (SpTagDirEntry_t FAR *) lockBuffer (ProfileData->TagArray); /* call users function ONLY IF VALID ENTRY */ if (tagArray[index].TagDataSize != -1) Status = SpDoIter(TagIterFunc, SpIterProcessing, Profile, tagArray[index].TagId, Data); } unlockBuffer (ProfileData->TagArray); SpDoIter ( TagIterFunc, SpIterTerm, NULL, 0, Data); SpProfileUnlock (Profile); return Status; }
/*-------------------------------------------------------------------- * DESCRIPTION (Public) * Set the name of the file to associate with the profile. * If the Name is NULL no file will be associated with the profile. * * AUTHOR * lsh & mlb * * DATE Copied * November 15, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileSetName ( SpProfile_t Profile, KpChar_t *FileName, SpFileProps_t *Props) { char FAR *fileName; SpProfileData_t FAR *ProfileData; SpStatus_t status; /* convert profile handle to data pointer */ ProfileData = SpProfileLock (Profile); if (NULL == ProfileData) return SpStatBadProfile; /* Free current FileName if one is there */ if (ProfileData->FileName != NULL) { if (ProfileData->TagArray == NULL) status = SpProfilePopTagArray(ProfileData); freeBuffer(ProfileData->FileName); } /* create the FileName handle */ ProfileData->FileName = allocBufferHandle (strlen (FileName) + 1); if (ProfileData->FileName == NULL) return SpStatMemory; /* lock FileName handle and return ptr */ fileName = (char *) lockBuffer (ProfileData->FileName); if (fileName == NULL) return SpStatMemory; /* copy text data into the newly allocated space */ strcpy (fileName, FileName); /* Copy props information into internal profile data structure */ #if defined (KPMAC) SpProfSetSpFileProps (Props, &(ProfileData->Props)); #endif /* unlock handles */ unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatSuccess; }
/*-------------------------------------------------------------------- * DESCRIPTION * This function inverts the input tables of a PT * * AUTHOR * PGT * * DATE CREATED * May 11, 1994 *--------------------------------------------------------------------*/ static PTErr_t InvertInputTables ( PTRefNum_t refNum, KpInt32_t numOutChan, KpInt32_t FAR *numInVar) { KpInt32_t in, out, k; PTErr_t cpStatus; KcmHandle refTblHandle; mf2_tbldat_p refTbl; mf2_tbldat_t refTblTemp; KcmHandle tblList[FUT_NOCHAN * FUT_NICHAN]; KpInt32_t numTbls, refTblEntries; /* Get each table, invert if not already inverted */ cpStatus = KCP_SUCCESS; for (out = 0, numTbls = 0; (out < numOutChan) && (cpStatus == KCP_SUCCESS); ++out) { for (in = 0; (in < numInVar [out]) && (cpStatus == KCP_SUCCESS); ++in) { cpStatus = getRefTbl (FUT_IMAGIC, refNum, in, out, &refTblHandle, &refTblEntries); if (cpStatus == KCP_NO_INTABLE) { /* no input tbl, ignore */ cpStatus = KCP_SUCCESS; } else { if ((cpStatus == KCP_SUCCESS) && (UniqueTable (refTblHandle, tblList, numTbls))) { refTbl = lockBuffer (refTblHandle); if (refTbl != NULL) { tblList [numTbls++] = refTblHandle; /* save address to avoid multiple inversion */ for (k = 0; k < refTblEntries/2; ++k) { /* invert the table */ refTblTemp = refTbl [k]; /* by reversing the order of the entries */ refTbl [k] = refTbl [refTblEntries-1-k]; refTbl [refTblEntries-1-k] = refTblTemp; } unlockBuffer (refTblHandle); } else { cpStatus = KCP_MEM_LOCK_ERR; } } } } } return cpStatus; }
void GraphicsDeviceGL_1_3::drawVirtualScreen() { glViewport( m_virtualViewport[0], m_virtualViewport[1], m_virtualViewport[2], m_virtualViewport[3] ); //update the video memory framebuffer. lockBuffer(); if (m_writeFrame > m_renderFrame) { m_videoFrameBuffer->update( m_frameWidth, m_frameHeight, m_frameBuffer_32bpp[m_writeBufferIndex] ); } m_renderFrame = m_writeFrame; unlockBuffer(); enableBlending(false); drawFullscreenQuad(m_videoFrameBuffer); glViewport( m_fullViewport[0], m_fullViewport[1], m_fullViewport[2], m_fullViewport[3] ); }
void String8::toUpper(size_t start, size_t length) { const size_t len = size(); if (start >= len) { return; } if (start + length > len) { length = len - start; } char* buf = lockBuffer(len); buf += start; while (length > 0) { *buf = toupper(*buf); buf++; length--; } unlockBuffer(len); }
void GraphicsDeviceOGL::convertFrameBufferTo32bpp(u8* source, u32* pal) { lockBuffer(); const s32 curIndex = m_bufferIndex; u32 *dest = m_frameBuffer_32bpp[curIndex]; u32 pixelCount = m_frameWidth*m_frameHeight; for (u32 p=0; p<pixelCount; p++) { *dest = pal[ *source ]; dest++; source++; } m_writeBufferIndex = m_bufferIndex; m_bufferIndex = (m_bufferIndex+1)&1; m_writeFrame++; unlockBuffer(); }
/*-------------------------------------------------------------------- * DESCRIPTION (Public) * Return the name of the currently associated file. * * AUTHOR * lsh * * DATE CREATED * September 20, 1993 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileGetDiskName ( SpProfile_t Profile, size_t BufferSize, KpChar_t *Buffer, SpIOFileChar_t *Props) { char FAR *fileName; SpProfileData_t FAR *ProfileData; /* convert profile handle to data pointer */ ProfileData = SpProfileLock (Profile); if (NULL == ProfileData) return SpStatBadProfile; /* lock FileName handle and return ptr */ fileName = (char *) lockBuffer (ProfileData->FileName); /* check for case of no file name */ if (NULL == fileName) { *Buffer = '\0'; SpProfileUnlock (Profile); return SpStatNoFileName; } /* check for buffer large enough */ if (BufferSize < strlen (fileName) + 1) { unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatBufferTooSmall; } strcpy (Buffer, fileName); /* Get file properties */ #if defined (KPMAC) SpProfSetSpFileData (&(ProfileData->Props), Props); #endif /* unlock handles */ unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatSuccess; }
status_t String8::appendFormat(const char* fmt, ...) { va_list ap; va_start(ap, fmt); int result = NO_ERROR; int n = vsnprintf(NULL, 0, fmt, ap); if (n != 0) { size_t oldLength = length(); char* buf = lockBuffer(oldLength + n); if (buf) { vsnprintf(buf + oldLength, n + 1, fmt, ap); } else { result = NO_MEMORY; } } va_end(ap); return result; }
/*-------------------------------------------------------------------- * DESCRIPTION * This function inverts the output tables of a PT * * AUTHOR * PGT * * DATE CREATED * May 11, 1994 *--------------------------------------------------------------------*/ static PTErr_t InvertOutputTables ( PTRefNum_t refNum, KpInt32_t numOutChan) { KpInt32_t i, k; PTErr_t cpStatus; KcmHandle refTblHandle; KcmHandle tblList[FUT_NOCHAN]; mf2_tbldat_p refTbl; KpInt32_t numTbls, refTblEntries, dummy = 0; /* Get each table, invert if not already inverted */ cpStatus = KCP_SUCCESS; numTbls = 0; for (i = 0; (i < numOutChan) && (cpStatus == KCP_SUCCESS); ++i) { cpStatus = getRefTbl (FUT_OMAGIC, refNum, dummy, i, &refTblHandle, &refTblEntries); if (cpStatus == KCP_NO_OUTTABLE) { cpStatus = KCP_SUCCESS; } else { if ((cpStatus == KCP_SUCCESS) && (UniqueTable (refTblHandle, tblList, numTbls))) { refTbl = lockBuffer (refTblHandle); if (refTbl != NULL) { tblList [numTbls++] = refTblHandle; /* save address to avoid multiple inversion */ for (k = 0; k < refTblEntries; ++k ) { /* invert the table */ refTbl[k] = (mf2_tbldat_t)(MF2_TBL_MAXVAL - refTbl[k]); /* by negating the contents of each entry */ } unlockBuffer (refTblHandle); } else { cpStatus = KCP_MEM_LOCK_ERR; } } } } return cpStatus; }
/*-------------------------------------------------------------------- * DESCRIPTION (Private -- phase out 5/4/95) * Set the name of the file to associate with the profile. * If the Name is NULL no file will be associated with the profile. * * AUTHOR * lsh * * DATE CREATED * Octorber 22, 1993 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileSetFileName ( SpProfile_t Profile, char FAR *FileName) { char FAR *fileName; SpProfileData_t FAR *ProfileData; /* convert profile handle to data pointer */ ProfileData = SpProfileLock (Profile); if (NULL == ProfileData) return SpStatBadProfile; /* Free current FileName if one is there */ if (ProfileData->FileName != NULL) freeBuffer(ProfileData->FileName); /* create the FileName handle */ ProfileData->FileName = allocBufferHandle (strlen (FileName) + 1); if (ProfileData->FileName == NULL) return (SpStatMemory); /* lock FileName handle and return ptr */ fileName = (char *) lockBuffer (ProfileData->FileName); if (fileName == NULL) return (SpStatMemory); /* copy text data into the newly allocated space */ strcpy (fileName, FileName); #if defined (KPMAC) SpProfileClearProps(&(ProfileData->Props)); #endif /* unlock handles */ unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatSuccess; }
/*-------------------------------------------------------------------- * DESCRIPTION (Private -- phase out 5/4/95) * Return the name of the currently associated file. * * AUTHOR * lsh * * DATE CREATED * September 20, 1993 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileGetFileName ( SpProfile_t Profile, size_t BufferSize, char FAR *Buffer) { char FAR *fileName; SpProfileData_t FAR *ProfileData; /* convert profile handle to data pointer */ ProfileData = SpProfileLock (Profile); if (NULL == ProfileData) return SpStatBadProfile; /* lock FileName handle and return ptr */ fileName = (char *) lockBuffer (ProfileData->FileName); /* check for case of no file name */ if (NULL == fileName) { *Buffer = '\0'; SpProfileUnlock (Profile); return SpStatNoFileName; } /* check for buffer large enough */ if (BufferSize < strlen (fileName) + 1) { unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatBufferTooSmall; } strcpy (Buffer, fileName); /* unlock handles */ unlockBuffer (ProfileData->FileName); SpProfileUnlock (Profile); return SpStatSuccess; }
bool String8::removeAll(const char* other) { ssize_t index = find(other); if (index < 0) return false; char* buf = lockBuffer(size()); if (!buf) return false; // out of memory size_t skip = strlen(other); size_t len = size(); size_t tail = index; while (size_t(index) < len) { ssize_t next = find(other, index + skip); if (next < 0) { next = len; } memmove(buf + tail, buf + index + skip, next - index - skip); tail += next - index - skip; index = next; } unlockBuffer(tail); return true; }
String8& String8::appendPath(const char* name) { // TODO: The test below will fail for Win32 paths. Fix later or ignore. if (name[0] != OS_PATH_SEPARATOR) { if (*name == '\0') { // nothing to do return *this; } size_t len = length(); if (len == 0) { // no existing filename, just use the new one setPathName(name); return *this; } // make room for oldPath + '/' + newPath int newlen = strlen(name); char* buf = lockBuffer(len + 1 + newlen); // insert a '/' if needed if (buf[len - 1] != OS_PATH_SEPARATOR) buf[len++] = OS_PATH_SEPARATOR; memcpy(buf + len, name, newlen + 1); len += newlen; unlockBuffer(len); return *this; } else { setPathName(name); return *this; } }
status_t String8::appendFormatV(const char* fmt, va_list args) { int n, result = NO_ERROR; va_list tmp_args; /* args is undefined after vsnprintf. * So we need a copy here to avoid the * second vsnprintf access undefined args. */ va_copy(tmp_args, args); n = vsnprintf(NULL, 0, fmt, tmp_args); va_end(tmp_args); if (n != 0) { size_t oldLength = length(); char* buf = lockBuffer(oldLength + n); if (buf) { vsnprintf(buf + oldLength, n + 1, fmt, args); } else { result = NO_MEMORY; } } return result; }
KpGenericPtr_t lockSysBuffer (KpHandle_t handle) { return (lockBuffer (handle)); }