]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.c
ShellPkg: Replace BSD License with BSD+Patent License
[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 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "TextEditor.h"
10 #include "Misc.h"
11
12 /**
13 Duplicate a EFI_EDITOR_LINE structure.
14
15 @param Src The line structure to copy from.
16
17 @retval NULL A memory allocation failed.
18 @return a pointer to the newly allcoated line.
19 **/
20 EFI_EDITOR_LINE *
21 LineDup (
22 IN EFI_EDITOR_LINE *Src
23 )
24 {
25 EFI_EDITOR_LINE *Dest;
26
27 //
28 // allocate for the line structure
29 //
30 Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
31 if (Dest == NULL) {
32 return NULL;
33 }
34 //
35 // allocate and set the line buffer
36 //
37 Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);
38 if (Dest->Buffer == NULL) {
39 FreePool (Dest);
40 return NULL;
41 }
42
43 //
44 // set the other structure members
45 //
46 Dest->Signature = LINE_LIST_SIGNATURE;
47 Dest->Size = Src->Size;
48 Dest->TotalSize = Dest->Size;
49 Dest->Type = Src->Type;
50 Dest->Link = Src->Link;
51
52 return Dest;
53 }
54
55 /**
56 Free a EFI_EDITOR_LINE structure.
57
58 @param Src The line structure to free.
59 **/
60 VOID
61 LineFree (
62 IN EFI_EDITOR_LINE *Src
63 )
64 {
65 if (Src == NULL) {
66 return ;
67 }
68 //
69 // free the line buffer and then the line structure itself
70 //
71 SHELL_FREE_NON_NULL (Src->Buffer);
72 SHELL_FREE_NON_NULL (Src);
73
74 }
75
76
77
78
79
80
81
82
83
84