Changeset 909771e


Ignore:
Timestamp:
Dec 6, 2008, 2:33:28 AM (12 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
de1c8a5
Parents:
19bab8e
git-author:
Anders Kaseorg <andersk@mit.edu> (12/06/08 01:21:06)
git-committer:
Anders Kaseorg <andersk@mit.edu> (12/06/08 02:33:28)
Message:
Simplify Perl string copying with owl_strdup().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r19bab8e r909771e  
    182182  dSP ;
    183183  int count;
    184   unsigned int len;
    185184  SV *msgref, *srv;
    186   char *out, *preout;
     185  char *out;
    187186 
    188187  ENTER ;
     
    212211
    213212  if (srv) {
    214     preout=SvPV(srv, len);
    215     out = owl_malloc(strlen(preout)+1);
    216     strncpy(out, preout, len);
    217     out[len] = '\0';
     213    out = owl_strdup(SvPV_nolen(srv));
    218214  } else {
    219215    out = NULL;
     
    234230{
    235231  dSP;
    236   unsigned int count, len, i;
     232  unsigned int count, i;
    237233  SV *msgref, *srv;
    238   char *out, *preout;
     234  char *out;
    239235
    240236  msgref = owl_perlconfig_message2hashref(m);
     
    268264
    269265  if (srv) {
    270     preout=SvPV(srv, len);
    271     out = owl_malloc(strlen(preout)+1);
    272     strncpy(out, preout, len);
    273     out[len] = '\0';
     266    out = owl_strdup(SvPV_nolen(srv));
    274267  } else {
    275268    out = NULL;
     
    395388
    396389  preout=SvPV(response, len);
    397   /* leave enough space in case we have to add a newline */
    398   out = owl_malloc(strlen(preout)+2);
    399   strncpy(out, preout, len);
    400   out[len] = '\0';
    401   if (!strlen(out) || out[strlen(out)-1]!='\n') {
    402     strcat(out, "\n");
    403   }
     390  if (len == 0 || preout[len - 1] != '\n')
     391    out = owl_sprintf("%s\n", preout);
     392  else
     393    out = owl_strdup(preout);
    404394
    405395  return(out);
Note: See TracChangeset for help on using the changeset viewer.