MCPcopy Create free account
hub / github.com/cinience/RedisStudio / Format

Method Format

DuiLib/Utils/Utils.cpp:708–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706 }
707
708 int CDuiString::Format(LPCTSTR pstrFormat, va_list Args)
709 {
710#if _MSC_VER <= 1400
711
712 TCHAR *szBuffer = NULL;
713 int size = 512, nLen, counts;
714
715 //
716 // allocate with init size
717 //
718
719 szBuffer = (TCHAR*)malloc(size);
720 ZeroMemory(szBuffer, size);
721
722 while (TRUE){
723 counts = size / sizeof(TCHAR);
724 nLen = _vsntprintf (szBuffer, counts, pstrFormat, Args);
725 if (nLen != -1 && nLen < counts){
726 break;
727 }
728
729 //
730 // expand the buffer.
731 //
732
733 if (nLen == -1){
734 size *= 2;
735 }else{
736 size += 1 * sizeof(TCHAR);
737 }
738
739
740 //
741 // realloc the buffer.
742 //
743
744 if ((szBuffer = (TCHAR*)realloc(szBuffer, size)) != NULL){
745 ZeroMemory(szBuffer, size);
746 }else{
747 break;
748 }
749
750 }
751
752 Assign(szBuffer);
753 free(szBuffer);
754 return nLen;
755#else
756 int nLen, totalLen;
757 TCHAR *szBuffer;
758
759 nLen = _vsntprintf(NULL, 0, pstrFormat, Args);
760 totalLen = (nLen + 1)*sizeof(TCHAR);
761 szBuffer = (TCHAR*)malloc(totalLen);
762 ZeroMemory(szBuffer, totalLen);
763 nLen = _vsntprintf(szBuffer, nLen + 1, pstrFormat, Args);
764
765 Assign(szBuffer);

Callers 7

SetHomePageMethod · 0.80
DUI__TraceFunction · 0.80
OnPaginateMethod · 0.80
OnDataVerboseMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected