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