Explorar o código

* strnew is ofcourse also different between sysutils and strings, just
like stralloc/strdispose.

peter %!s(int64=26) %!d(string=hai) anos
pai
achega
b1ce2dee62
Modificáronse 3 ficheiros con 53 adicións e 23 borrados
  1. 26 7
      rtl/inc/strings.pp
  2. 5 15
      rtl/inc/stringsi.inc
  3. 22 1
      rtl/objpas/syspch.inc

+ 26 - 7
rtl/inc/strings.pp

@@ -103,25 +103,44 @@ implementation
 
 { Functions, different from the one in sysutils }
 
-    procedure strdispose(p : pchar);
+    function stralloc(L : longint) : pchar;
 
       begin
-         if p<>nil then
-           freemem(p,strlen(p)+1);
+         StrAlloc:=Nil;
+         GetMem (Stralloc,l);
       end;
 
-    function stralloc(L : longint) : pchar;
+    function strnew(p : pchar) : pchar;
+
+      var
+         len : longint;
 
       begin
-         StrAlloc:=Nil;
-         GetMem (Stralloc,l);
+         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

+ 5 - 15
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

+ 22 - 1
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