From b1ce2dee62d6f8c01ec3c0312aa79568cea7cb0a Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 10 Dec 1999 15:02:12 +0000 Subject: [PATCH] * strnew is ofcourse also different between sysutils and strings, just like stralloc/strdispose. --- rtl/inc/strings.pp | 35 +++++++++++++++++++++++++++-------- rtl/inc/stringsi.inc | 20 +++++--------------- rtl/objpas/syspch.inc | 23 ++++++++++++++++++++++- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/rtl/inc/strings.pp b/rtl/inc/strings.pp index a83f331911..d1915a5b5f 100644 --- a/rtl/inc/strings.pp +++ b/rtl/inc/strings.pp @@ -103,13 +103,6 @@ implementation { Functions, different from the one in sysutils } - procedure strdispose(p : pchar); - - begin - if p<>nil then - freemem(p,strlen(p)+1); - end; - function stralloc(L : longint) : pchar; begin @@ -117,11 +110,37 @@ implementation GetMem (Stralloc,l); end; + function strnew(p : pchar) : pchar; + + var + len : longint; + + begin + strnew:=nil; + if (p=nil) or (p^=#0) then + exit; + len:=strlen(p)+1; + getmem(strnew,len); + if strnew<>nil then + strmove(strnew,p,len); + end; + + procedure strdispose(p : pchar); + + begin + if p<>nil then + freemem(p,strlen(p)+1); + end; + end. { $Log$ - Revision 1.1 1999-02-25 07:42:03 michael + Revision 1.2 1999-12-10 15:02:12 peter + * strnew is ofcourse also different between sysutils and strings, just + like stralloc/strdispose. + + Revision 1.1 1999/02/25 07:42:03 michael * Joined strings and sysutils Revision 1.7 1998/08/05 08:59:53 michael diff --git a/rtl/inc/stringsi.inc b/rtl/inc/stringsi.inc index 0c91d87dca..7239afc61e 100644 --- a/rtl/inc/stringsi.inc +++ b/rtl/inc/stringsi.inc @@ -66,23 +66,13 @@ end; end; - function strnew(p : pchar) : pchar; - - var - len : longint; - - begin - strnew:=nil; - if (p=nil) or (p^=#0) then - exit; - len:=strlen(p)+1; - getmem(strnew,len); - if strnew<>nil then - strmove(strnew,p,len); - end; { $Log$ - Revision 1.4 1999-09-13 11:42:42 peter + Revision 1.5 1999-12-10 15:02:12 peter + * strnew is ofcourse also different between sysutils and strings, just + like stralloc/strdispose. + + Revision 1.4 1999/09/13 11:42:42 peter * fixed strlcat Revision 1.3 1999/09/01 09:25:10 peter diff --git a/rtl/objpas/syspch.inc b/rtl/objpas/syspch.inc index d2e8d22e02..6c90f0c645 100644 --- a/rtl/objpas/syspch.inc +++ b/rtl/objpas/syspch.inc @@ -54,6 +54,23 @@ begin end; +{ Allocates a new string using StrAlloc, you need StrDispose to dispose the + string } + +function strnew(p : pchar) : pchar; +var + len : longint; +begin + strnew:=nil; + if (p=nil) or (p^=#0) then + exit; + len:=strlen(p)+1; + StrNew:=StrAlloc(Len); + if strnew<>nil then + strmove(strnew,p,len); +end; + + { StrPCopy copies the pascal string Source to Dest and returns Dest } function StrPCopy(Dest: PChar; Source: string): PChar; @@ -101,7 +118,11 @@ end ; { $Log$ - Revision 1.7 1999-11-06 14:41:31 peter + Revision 1.8 1999-12-10 15:02:12 peter + * strnew is ofcourse also different between sysutils and strings, just + like stralloc/strdispose. + + Revision 1.7 1999/11/06 14:41:31 peter * truncated log Revision 1.6 1999/08/24 13:14:50 peter