]>
Commit | Line | Data |
---|---|---|
632820d1 | 1 | /** @file\r |
2 | Implementation of various string and line routines.\r | |
3 | \r | |
4 | Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r | |
56ba3746 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
632820d1 | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "TextEditor.h"\r | |
10 | #include "Misc.h"\r | |
11 | \r | |
12 | /**\r | |
13 | Duplicate a EFI_EDITOR_LINE structure.\r | |
14 | \r | |
15 | @param Src The line structure to copy from.\r | |
16 | \r | |
17 | @retval NULL A memory allocation failed.\r | |
18 | @return a pointer to the newly allcoated line.\r | |
19 | **/\r | |
20 | EFI_EDITOR_LINE *\r | |
632820d1 | 21 | LineDup (\r |
22 | IN EFI_EDITOR_LINE *Src\r | |
23 | )\r | |
24 | {\r | |
25 | EFI_EDITOR_LINE *Dest;\r | |
26 | \r | |
27 | //\r | |
28 | // allocate for the line structure\r | |
29 | //\r | |
30 | Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));\r | |
31 | if (Dest == NULL) {\r | |
32 | return NULL;\r | |
33 | }\r | |
34 | //\r | |
35 | // allocate and set the line buffer\r | |
36 | //\r | |
37 | Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);\r | |
38 | if (Dest->Buffer == NULL) {\r | |
39 | FreePool (Dest);\r | |
40 | return NULL;\r | |
41 | }\r | |
42 | \r | |
43 | //\r | |
44 | // set the other structure members\r | |
45 | //\r | |
46 | Dest->Signature = LINE_LIST_SIGNATURE;\r | |
47 | Dest->Size = Src->Size;\r | |
48 | Dest->TotalSize = Dest->Size;\r | |
49 | Dest->Type = Src->Type;\r | |
50 | Dest->Link = Src->Link;\r | |
51 | \r | |
52 | return Dest;\r | |
53 | }\r | |
54 | \r | |
55 | /**\r | |
56 | Free a EFI_EDITOR_LINE structure.\r | |
57 | \r | |
58 | @param Src The line structure to free.\r | |
59 | **/\r | |
60 | VOID\r | |
632820d1 | 61 | LineFree (\r |
62 | IN EFI_EDITOR_LINE *Src\r | |
63 | )\r | |
64 | {\r | |
65 | if (Src == NULL) {\r | |
66 | return ;\r | |
67 | }\r | |
68 | //\r | |
69 | // free the line buffer and then the line structure itself\r | |
70 | //\r | |
71 | SHELL_FREE_NON_NULL (Src->Buffer);\r | |
72 | SHELL_FREE_NON_NULL (Src);\r | |
73 | \r | |
74 | }\r | |
75 | \r | |
76 | \r | |
77 | \r | |
78 | \r | |
79 | \r | |
80 | \r | |
81 | \r | |
82 | \r | |
83 | \r | |
84 | \r |