To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1174
1173  |  1175
Subject: 
memory leak in string handling
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 20 Jun 2000 09:17:15 GMT
Viewed: 
1247 times
  
This is not, as far as I know, something that is the matter with legos, but
rather with my C programming skills. I'm trying to write the function
strcat, but apparantly I'm losing memory somewhere.
If anyone can see any apparant leak, please let me know. Thanks

char* strcat(char *dest,const char *src) {
  char *d2=dest;

  while(*(d2++) != 0)
    ;

  while( ( *(d2++) = *(src++) ) != 0)
   ;

  return dest;
}



Message has 3 Replies:
  (canceled)
 
  Re: memory leak in string handling
 
(...) I don't know of any leaks, but this line includes the terminating \0 in the output string: (...) Try the following instead: while (*d2) d2++; Presumably if you allocated a buffer of exactly the right size for a correct strcat, you code would (...) (24 years ago, 20-Jun-00, to lugnet.robotics.rcx.legos)
  (canceled)
 

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR