OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
AsciiStringBuffer.c File Reference
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcFlexArrayLib.h>
#include <Library/PrintLib.h>

Go to the source code of this file.

Functions

OC_ASCII_STRING_BUFFEROcAsciiStringBufferInit (VOID)
 
EFI_STATUS OcAsciiStringBufferAppend (IN OUT OC_ASCII_STRING_BUFFER *Buffer, IN CONST CHAR8 *AppendString OPTIONAL)
 
STATIC EFI_STATUS InternalAsciiStringBufferExtendBy (IN OUT OC_ASCII_STRING_BUFFER *Buffer, IN CONST UINTN AppendLength, OUT UINTN *TargetLength)
 
EFI_STATUS OcAsciiStringBufferAppendN (IN OUT OC_ASCII_STRING_BUFFER *Buffer, IN CONST CHAR8 *AppendString, OPTIONAL IN CONST UINTN Length)
 
EFI_STATUS EFIAPI OcAsciiStringBufferSPrint (IN OUT OC_ASCII_STRING_BUFFER *Buffer, IN CONST CHAR8 *FormatString,...)
 
CHAR8 * OcAsciiStringBufferFreeContainer (IN OUT OC_ASCII_STRING_BUFFER **StringBuffer)
 
VOID OcAsciiStringBufferFree (IN OUT OC_ASCII_STRING_BUFFER **StringBuffer)
 

Detailed Description

String buffer.

Copyright (c) 2021, Mike Beaton. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause

Definition in file AsciiStringBuffer.c.

Function Documentation

◆ InternalAsciiStringBufferExtendBy()

STATIC EFI_STATUS InternalAsciiStringBufferExtendBy ( IN OUT OC_ASCII_STRING_BUFFER * Buffer,
IN CONST UINTN AppendLength,
OUT UINTN * TargetLength )

Extend string buffer by a specified length.

Parameters
[in,out]BufferString buffer to be extended.
[in]AppendLengthLength to be appended.
[out]TargetLengthTarget length of the extended buffer.
Return values
EFI_SUCCESSThe buffer was extended successfully.
EFI_OUT_OF_RESOURCESThe extension failed due to the lack of resources.
EFI_UNSUPPORTEDThe buffer has no size.

Definition at line 50 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferAppend()

EFI_STATUS OcAsciiStringBufferAppend ( IN OUT OC_ASCII_STRING_BUFFER * Buffer,
IN CONST CHAR8 *AppendString OPTIONAL )

Append new string to buffer, resizing if necessary.

Parameters
[in,out]StringBufferBuffer to modify.
[in]AppendStringString to append. If NULL, nothing will be modified.
Return values
EFI_SUCCESSString was appended.
EFI_OUT_OF_RESOURCESOut of memory.
EFI_UNSUPPORTEDInternal error.

Definition at line 29 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferAppendN()

EFI_STATUS OcAsciiStringBufferAppendN ( IN OUT OC_ASCII_STRING_BUFFER * Buffer,
IN CONST CHAR8 * AppendString,
OPTIONAL IN CONST UINTN Length )

Append new substring to buffer, resizing if necessary.

Parameters
[in,out]StringBufferBuffer to modify.
[in]AppendStringString to append. If NULL, nothing will be modified.
[in]LengthMaxiumum length of substring to use. 0 means use 0 characters. Use MAX_UINTN for all chars. Ignored if AppendString is NULL.
Return values
EFI_SUCCESSString was appended.
EFI_OUT_OF_RESOURCESOut of memory.
EFI_UNSUPPORTEDInternal error.

Definition at line 101 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferFree()

VOID OcAsciiStringBufferFree ( IN OUT OC_ASCII_STRING_BUFFER ** StringBuffer)

Free string buffer memory; free and discard any allocated resultant string.

Parameters
[in,out]StringBufferStringBuffer to free.
Return values
Non-NULLPointer to pool allocated accumulated string.
NULLNo data was ever added to the string.

Definition at line 197 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferFreeContainer()

CHAR8 * OcAsciiStringBufferFreeContainer ( IN OUT OC_ASCII_STRING_BUFFER ** StringBuffer)

Free string buffer memory and return pointer to pool allocated resultant string. Note that if no data was ever appended to the string then the return value will be NULL, not a zero length string.

Parameters
[in,out]StringBufferStringBuffer to free.
Return values
Non-NULLPointer to pool allocated accumulated string.
NULLNo data was ever added to the string.

Definition at line 178 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferInit()

OC_ASCII_STRING_BUFFER * OcAsciiStringBufferInit ( VOID )

Initialize string buffer.

Return values
Non-NULLBuffer was created.
NULLOut of memory.

Definition at line 17 of file AsciiStringBuffer.c.

◆ OcAsciiStringBufferSPrint()

EFI_STATUS EFIAPI OcAsciiStringBufferSPrint ( IN OUT OC_ASCII_STRING_BUFFER * Buffer,
IN CONST CHAR8 * FormatString,
... )

Safely print to string buffer.

Parameters
[in,out]StringBufferBuffer to modify.
[in]FormatStringA Null-terminated ASCII format string.
[in]...Variable argument list whose contents are accessed based on the format string specified by FormatString.
Return values
EFI_SUCCESSWhen data was printed to string buffer.
EFI_OUT_OF_RESOURCESOut of memory increasing string buffer sufficiently to print to.

Definition at line 140 of file AsciiStringBuffer.c.