]>
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 | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "TextEditor.h"\r | |
16 | #include "Misc.h"\r | |
17 | \r | |
18 | /**\r | |
19 | Duplicate a EFI_EDITOR_LINE structure.\r | |
20 | \r | |
21 | @param Src The line structure to copy from.\r | |
22 | \r | |
23 | @retval NULL A memory allocation failed.\r | |
24 | @return a pointer to the newly allcoated line.\r | |
25 | **/\r | |
26 | EFI_EDITOR_LINE *\r | |
632820d1 | 27 | LineDup (\r |
28 | IN EFI_EDITOR_LINE *Src\r | |
29 | )\r | |
30 | {\r | |
31 | EFI_EDITOR_LINE *Dest;\r | |
32 | \r | |
33 | //\r | |
34 | // allocate for the line structure\r | |
35 | //\r | |
36 | Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));\r | |
37 | if (Dest == NULL) {\r | |
38 | return NULL;\r | |
39 | }\r | |
40 | //\r | |
41 | // allocate and set the line buffer\r | |
42 | //\r | |
43 | Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);\r | |
44 | if (Dest->Buffer == NULL) {\r | |
45 | FreePool (Dest);\r | |
46 | return NULL;\r | |
47 | }\r | |
48 | \r | |
49 | //\r | |
50 | // set the other structure members\r | |
51 | //\r | |
52 | Dest->Signature = LINE_LIST_SIGNATURE;\r | |
53 | Dest->Size = Src->Size;\r | |
54 | Dest->TotalSize = Dest->Size;\r | |
55 | Dest->Type = Src->Type;\r | |
56 | Dest->Link = Src->Link;\r | |
57 | \r | |
58 | return Dest;\r | |
59 | }\r | |
60 | \r | |
61 | /**\r | |
62 | Free a EFI_EDITOR_LINE structure.\r | |
63 | \r | |
64 | @param Src The line structure to free.\r | |
65 | **/\r | |
66 | VOID\r | |
632820d1 | 67 | LineFree (\r |
68 | IN EFI_EDITOR_LINE *Src\r | |
69 | )\r | |
70 | {\r | |
71 | if (Src == NULL) {\r | |
72 | return ;\r | |
73 | }\r | |
74 | //\r | |
75 | // free the line buffer and then the line structure itself\r | |
76 | //\r | |
77 | SHELL_FREE_NON_NULL (Src->Buffer);\r | |
78 | SHELL_FREE_NON_NULL (Src);\r | |
79 | \r | |
80 | }\r | |
81 | \r | |
82 | \r | |
83 | \r | |
84 | \r | |
85 | \r | |
86 | \r | |
87 | \r | |
88 | \r | |
89 | \r | |
90 | \r |