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