Changeset 59916e8


Ignore:
Timestamp:
Feb 23, 2007, 3:21:48 PM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f166580
Parents:
be5aa09
Message:
Once more, dealing better with free().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    rbe5aa09 r59916e8  
    743743char * owl_util_baseclass(char * class)
    744744{
    745   char * newClass;
    746   char * end;
    747   newClass = owl_strdup(class);
    748   while(!strncmp(newClass, "un", 2)) {
    749     newClass += 2;
    750   }
    751   end = newClass + strlen(newClass) - 1;
     745  char *newClass;
     746  char *ret;
     747  char *start, *end;
     748
     749  start = newClass = owl_strdup(class);
     750  while(!strncmp(start, "un", 2)) {
     751    start += 2;
     752  }
     753  end = start + strlen(start) - 1;
    752754  while(*end == 'd' && *(end-1) == '.') {
    753755    end -= 2;
    754756  }
    755757  *(end + 1) = 0;
    756   return newClass;
     758
     759  ret = owl_strdup(start);
     760  owl_free(newClass);
     761
     762  return ret;
    757763}
    758764
Note: See TracChangeset for help on using the changeset viewer.