This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Re: strcat and config/darwin.c


This is really just a ping but it has been updated and changed some variable names in the patch.
This is also a simple speedup.


ChangeLog:

* config/darwin.c: (machopic_non_lazy_ptr_name): Change strcat to memcpy and add length together.
(machopic_stub_name): Likewise. (machopic_classify_ident): Change strcpy to memcpy.


Patch:

Index: darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.46
diff -u -p -r1.46 darwin.c
--- darwin.c	27 Sep 2003 04:48:11 -0000	1.46
+++ darwin.c	5 Oct 2003 01:03:38 -0000
@@ -294,20 +294,28 @@ machopic_non_lazy_ptr_name (const char *

   {
     char *buffer;
+    int namelen = strlen (name);
+    int bufferlen = 0;
     tree ptr_name;

-    buffer = alloca (strlen (name) + 20);
+    buffer = alloca (namelen + strlen("$non_lazy_ptr") + 5);

     strcpy (buffer, "&L");
+    bufferlen = 2;
     if (name[0] == '*')
-      strcat (buffer, name+1);
+      {
+        memcpy (buffer+bufferlen, name+1, namelen-1+1);
+        bufferlen += namelen-1;
+      }
     else
       {
-	strcat (buffer, "_");
-	strcat (buffer, name);
+	buffer[bufferlen] = '_';
+	memcpy (buffer+bufferlen+1, name, namelen+1);
+        bufferlen += namelen;
       }

- strcat (buffer, "$non_lazy_ptr");
+ memcpy (buffer + bufferlen, "$non_lazy_ptr", strlen("$non_lazy_ptr")+1);
+ bufferlen += strlen("$non_lazy_ptr");
ptr_name = get_identifier (buffer);


     machopic_non_lazy_pointers
@@ -351,29 +359,46 @@ machopic_stub_name (const char *name)

   {
     char *buffer;
+    int bufferlen = 0;
+    int namelen = strlen (name);
     tree ptr_name;
     int needs_quotes = name_needs_quotes (name);

-    buffer = alloca (strlen (name) + 20);
+    buffer = alloca (namelen + 20);

     if (needs_quotes)
-      strcpy (buffer, "&\"L");
+      {
+        strcpy (buffer, "&\"L");
+        bufferlen = strlen("&\"L");
+      }
     else
-      strcpy (buffer, "&L");
+      {
+        strcpy (buffer, "&L");
+        bufferlen = strlen("&L");
+      }
+
     if (name[0] == '*')
       {
-	strcat (buffer, name+1);
+	memcpy (buffer + bufferlen, name+1, namelen - 1 +1);
+        bufferlen += namelen - 1;
       }
     else
       {
-	strcat (buffer, "_");
-	strcat (buffer, name);
+	buffer[bufferlen] = '_';
+	memcpy (buffer + bufferlen +1, name, namelen+1);
+        bufferlen += namelen;
       }

     if (needs_quotes)
-      strcat (buffer, "$stub\"");
+      {
+        memcpy (buffer + bufferlen, "$stub\"", strlen("$stub\""));
+        bufferlen += strlen("$stub\"");
+      }
     else
-      strcat (buffer, "$stub");
+      {
+        memcpy (buffer + bufferlen, "$stub", strlen("$stub"));
+        bufferlen += strlen("$stub");
+      }
     ptr_name = get_identifier (buffer);

machopic_stubs = tree_cons (ptr_name, ident, machopic_stubs);




Attachment: strcat.diff
Description: Binary data





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]