Last change
on this file was 99404, checked in by vboxsync, 21 months ago |
Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | /** @file
|
---|
2 | Implementation of various string and line routines.
|
---|
3 |
|
---|
4 | Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include "TextEditor.h"
|
---|
10 | #include "Misc.h"
|
---|
11 |
|
---|
12 | /**
|
---|
13 | Duplicate a EFI_EDITOR_LINE structure.
|
---|
14 |
|
---|
15 | @param Src The line structure to copy from.
|
---|
16 |
|
---|
17 | @retval NULL A memory allocation failed.
|
---|
18 | @return a pointer to the newly allcoated line.
|
---|
19 | **/
|
---|
20 | EFI_EDITOR_LINE *
|
---|
21 | LineDup (
|
---|
22 | IN EFI_EDITOR_LINE *Src
|
---|
23 | )
|
---|
24 | {
|
---|
25 | EFI_EDITOR_LINE *Dest;
|
---|
26 |
|
---|
27 | //
|
---|
28 | // allocate for the line structure
|
---|
29 | //
|
---|
30 | Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
|
---|
31 | if (Dest == NULL) {
|
---|
32 | return NULL;
|
---|
33 | }
|
---|
34 |
|
---|
35 | //
|
---|
36 | // allocate and set the line buffer
|
---|
37 | //
|
---|
38 | Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);
|
---|
39 | if (Dest->Buffer == NULL) {
|
---|
40 | FreePool (Dest);
|
---|
41 | return NULL;
|
---|
42 | }
|
---|
43 |
|
---|
44 | //
|
---|
45 | // set the other structure members
|
---|
46 | //
|
---|
47 | Dest->Signature = LINE_LIST_SIGNATURE;
|
---|
48 | Dest->Size = Src->Size;
|
---|
49 | Dest->TotalSize = Dest->Size;
|
---|
50 | Dest->Type = Src->Type;
|
---|
51 | Dest->Link = Src->Link;
|
---|
52 |
|
---|
53 | return Dest;
|
---|
54 | }
|
---|
55 |
|
---|
56 | /**
|
---|
57 | Free a EFI_EDITOR_LINE structure.
|
---|
58 |
|
---|
59 | @param Src The line structure to free.
|
---|
60 | **/
|
---|
61 | VOID
|
---|
62 | LineFree (
|
---|
63 | IN EFI_EDITOR_LINE *Src
|
---|
64 | )
|
---|
65 | {
|
---|
66 | if (Src == NULL) {
|
---|
67 | return;
|
---|
68 | }
|
---|
69 |
|
---|
70 | //
|
---|
71 | // free the line buffer and then the line structure itself
|
---|
72 | //
|
---|
73 | SHELL_FREE_NON_NULL (Src->Buffer);
|
---|
74 | SHELL_FREE_NON_NULL (Src);
|
---|
75 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.