Home | Info | Community | Development | myReactOS | Contact Us
[static]
Definition at line 27 of file infput.c.
{ ULONG Length; PWCHAR NewBuf; ULONG NewSize; /* Skip mode? */ if (! INF_SUCCESS(OutBuf->Status)) { return; } /* Doesn't fit? */ Length = (ULONG)strlenW(Text) * sizeof(WCHAR); if (OutBuf->FreeSize < Length + 1 && INF_SUCCESS(OutBuf->Status)) { DPRINT("Out of free space. TotalSize %u FreeSize %u Length %u\n", (UINT)OutBuf->TotalSize, (UINT)OutBuf->FreeSize, (UINT)Length); /* Round up to next SIZE_INC */ NewSize = OutBuf->TotalSize + (((Length + 1) - OutBuf->FreeSize + (SIZE_INC - 1)) / SIZE_INC) * SIZE_INC; DPRINT("NewSize %u\n", (UINT)NewSize); NewBuf = MALLOC(NewSize); /* Abort if failed */ if (NULL == NewBuf) { DPRINT1("MALLOC() failed\n"); OutBuf->Status = INF_STATUS_NO_MEMORY; return; } /* Need to copy old contents? */ if (NULL != OutBuf->Buffer) { DPRINT("Copying %u bytes from old content\n", (UINT)(OutBuf->TotalSize - OutBuf->FreeSize)); MEMCPY(NewBuf, OutBuf->Buffer, OutBuf->TotalSize - OutBuf->FreeSize); OutBuf->Current = NewBuf + (OutBuf->Current - OutBuf->Buffer); FREE(OutBuf->Buffer); } else { OutBuf->Current = NewBuf; } OutBuf->Buffer = NewBuf; OutBuf->FreeSize += NewSize - OutBuf->TotalSize; OutBuf->TotalSize = NewSize; DPRINT("After reallocation TotalSize %u FreeSize %u\n", (UINT)OutBuf->TotalSize, (UINT)OutBuf->FreeSize); } /* We're guaranteed to have enough room now. Copy char by char because of possible "conversion" from Unicode to Ansi */ while (Length--) { *OutBuf->Current++ = *Text++; OutBuf->FreeSize--; } *OutBuf->Current = '\0'; }