]>
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 |
47d20b54 | 22 | IN EFI_EDITOR_LINE *Src\r |
632820d1 | 23 | )\r |
24 | {\r | |
47d20b54 | 25 | EFI_EDITOR_LINE *Dest;\r |
632820d1 | 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 | |
47d20b54 | 34 | \r |
632820d1 | 35 | //\r |
36 | // allocate and set the line buffer\r | |
37 | //\r | |
38 | Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);\r | |
39 | if (Dest->Buffer == NULL) {\r | |
40 | FreePool (Dest);\r | |
41 | return NULL;\r | |
42 | }\r | |
43 | \r | |
44 | //\r | |
45 | // set the other structure members\r | |
46 | //\r | |
47 | Dest->Signature = LINE_LIST_SIGNATURE;\r | |
48 | Dest->Size = Src->Size;\r | |
49 | Dest->TotalSize = Dest->Size;\r | |
50 | Dest->Type = Src->Type;\r | |
51 | Dest->Link = Src->Link;\r | |
52 | \r | |
53 | return Dest;\r | |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | Free a EFI_EDITOR_LINE structure.\r | |
58 | \r | |
59 | @param Src The line structure to free.\r | |
60 | **/\r | |
61 | VOID\r | |
632820d1 | 62 | LineFree (\r |
47d20b54 | 63 | IN EFI_EDITOR_LINE *Src\r |
632820d1 | 64 | )\r |
65 | {\r | |
66 | if (Src == NULL) {\r | |
47d20b54 | 67 | return;\r |
632820d1 | 68 | }\r |
47d20b54 | 69 | \r |
632820d1 | 70 | //\r |
71 | // free the line buffer and then the line structure itself\r | |
72 | //\r | |
73 | SHELL_FREE_NON_NULL (Src->Buffer);\r | |
74 | SHELL_FREE_NON_NULL (Src);\r | |
632820d1 | 75 | }\r |