]>
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 | |
27 | EFIAPI\r | |
28 | LineDup (\r | |
29 | IN EFI_EDITOR_LINE *Src\r | |
30 | )\r | |
31 | {\r | |
32 | EFI_EDITOR_LINE *Dest;\r | |
33 | \r | |
34 | //\r | |
35 | // allocate for the line structure\r | |
36 | //\r | |
37 | Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));\r | |
38 | if (Dest == NULL) {\r | |
39 | return NULL;\r | |
40 | }\r | |
41 | //\r | |
42 | // allocate and set the line buffer\r | |
43 | //\r | |
44 | Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);\r | |
45 | if (Dest->Buffer == NULL) {\r | |
46 | FreePool (Dest);\r | |
47 | return NULL;\r | |
48 | }\r | |
49 | \r | |
50 | //\r | |
51 | // set the other structure members\r | |
52 | //\r | |
53 | Dest->Signature = LINE_LIST_SIGNATURE;\r | |
54 | Dest->Size = Src->Size;\r | |
55 | Dest->TotalSize = Dest->Size;\r | |
56 | Dest->Type = Src->Type;\r | |
57 | Dest->Link = Src->Link;\r | |
58 | \r | |
59 | return Dest;\r | |
60 | }\r | |
61 | \r | |
62 | /**\r | |
63 | Free a EFI_EDITOR_LINE structure.\r | |
64 | \r | |
65 | @param Src The line structure to free.\r | |
66 | **/\r | |
67 | VOID\r | |
68 | EFIAPI\r | |
69 | LineFree (\r | |
70 | IN EFI_EDITOR_LINE *Src\r | |
71 | )\r | |
72 | {\r | |
73 | if (Src == NULL) {\r | |
74 | return ;\r | |
75 | }\r | |
76 | //\r | |
77 | // free the line buffer and then the line structure itself\r | |
78 | //\r | |
79 | SHELL_FREE_NON_NULL (Src->Buffer);\r | |
80 | SHELL_FREE_NON_NULL (Src);\r | |
81 | \r | |
82 | }\r | |
83 | \r | |
84 | \r | |
85 | \r | |
86 | \r | |
87 | \r | |
88 | \r | |
89 | \r | |
90 | \r | |
91 | \r | |
92 | \r |