~ubuntu-branches/ubuntu/wily/trafficserver/wily

« back to all changes in this revision

Viewing changes to lib/records/RecCore.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-12-17 22:28:16 UTC
  • mfrom: (5.1.8 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121217222816-7xwjsx5k76zkb63d
Tags: 3.2.0-1ubuntu1
* Revert FreeBSD strerror_r() fixes that give errors with glibc 2.16.
* Apply patch from Konstantinos Margaritis to define barriers on ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
  int len = -1;
166
166
  if (_ss) {
167
167
    len = strlen(_ss);
168
 
    _new_value = (RecString) xmalloc(len + 1);
 
168
    _new_value = (RecString)ats_malloc(len + 1);
169
169
    memcpy(_new_value, _ss, len + 1);
170
170
  }
171
171
 
172
172
  RecString _temp2 = data.rec_string;
173
173
  data.rec_string = _new_value;
174
 
 
175
 
  if (_temp2 != 0) {
176
 
    xfree(_temp2);
177
 
  }
 
174
  ats_free(_temp2);
178
175
 
179
176
  return REC_ERR_OKAY;
180
177
}
197
194
  g_num_records = 0;
198
195
 
199
196
  // initialize record array for our internal stats (this can be reallocated later)
200
 
  g_records = (RecRecord *) xmalloc(REC_MAX_RECORDS * sizeof(RecRecord));
 
197
  g_records = (RecRecord *)ats_malloc(REC_MAX_RECORDS * sizeof(RecRecord));
201
198
  memset(g_records, 0, REC_MAX_RECORDS * sizeof(RecRecord));
202
199
 
203
200
  // initialize record hash index
224
221
    bool file_exists = true;
225
222
    g_rec_config_fpath = Layout::relative_to(Layout::get()->sysconfdir, REC_CONFIG_FILE REC_SHADOW_EXT);
226
223
    if (RecFileExists(g_rec_config_fpath) == REC_ERR_FAIL) {
227
 
      xfree((char *)g_rec_config_fpath);
 
224
      ats_free((char *)g_rec_config_fpath);
228
225
      g_rec_config_fpath = Layout::relative_to(Layout::get()->sysconfdir, REC_CONFIG_FILE);
229
226
      if (RecFileExists(g_rec_config_fpath) == REC_ERR_FAIL) {
230
227
        RecLog(DL_Warning, "Could not find '%s', system will run with defaults\n", REC_CONFIG_FILE);
342
339
         }
343
340
       */
344
341
 
345
 
      RecConfigUpdateCbList *new_callback = (RecConfigUpdateCbList *) xmalloc(sizeof(RecConfigUpdateCbList));
 
342
      RecConfigUpdateCbList *new_callback = (RecConfigUpdateCbList *)ats_malloc(sizeof(RecConfigUpdateCbList));
346
343
      memset(new_callback, 0, sizeof(RecConfigUpdateCbList));
347
344
      new_callback->update_cb = update_cb;
348
345
      new_callback->update_cookie = cookie;
413
410
      if (r->data.rec_string == NULL) {
414
411
        buf[0] = '\0';
415
412
      } else {
416
 
        strncpy(buf, r->data.rec_string, buf_len - 1);
417
 
        buf[buf_len - 1] = '\0';
 
413
        ink_strlcpy(buf, r->data.rec_string, buf_len);
418
414
      }
419
415
    }
420
416
    rec_mutex_release(&(r->lock));
642
638
  RecRecord *r = NULL;
643
639
 
644
640
  if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) {
645
 
    *buf = (char *) xmalloc(sizeof(char) * 1024);
 
641
    *buf = (char *)ats_malloc(sizeof(char) * 1024);
646
642
    memset(*buf, 0, 1024);
647
643
    err = REC_ERR_OKAY;
648
644
 
655
651
      break;
656
652
    case RECD_STRING:
657
653
      if (r->data_default.rec_string) {
658
 
        strncpy(*buf, r->data_default.rec_string, 1023);
659
 
        buf[1023] = '\0';
 
654
        ink_strlcpy(*buf, r->data_default.rec_string, 1024);
660
655
      } else {
661
 
        xfree(*buf);
 
656
        ats_free(*buf);
662
657
        *buf = NULL;
663
658
      }
664
659
      break;
667
662
      break;
668
663
    default:
669
664
      ink_debug_assert(!"Unexpected RecD type");
670
 
      xfree(*buf);
 
665
      ats_free(*buf);
671
666
      *buf = NULL;
672
667
      break;
673
668
    }
765
760
    r->config_meta.update_type = update_type;
766
761
    r->config_meta.check_type = check_type;
767
762
    if (r->config_meta.check_expr) {
768
 
      xfree(r->config_meta.check_expr);
 
763
      ats_free(r->config_meta.check_expr);
769
764
    }
770
 
    r->config_meta.check_expr = xstrdup(check_expr);
 
765
    r->config_meta.check_expr = ats_strdup(check_expr);
771
766
    r->config_meta.update_cb_list = NULL;
772
767
    r->config_meta.access_type = access_type;
773
768
    rec_mutex_release(&(r->lock));
849
844
    r->config_meta.update_required = record->config_meta.update_required;
850
845
    r->config_meta.update_type = record->config_meta.update_type;
851
846
    r->config_meta.check_type = record->config_meta.check_type;
852
 
    if (r->config_meta.check_expr) {
853
 
      xfree(r->config_meta.check_expr);
854
 
    }
855
 
    r->config_meta.check_expr = xstrdup(record->config_meta.check_expr);
 
847
    ats_free(r->config_meta.check_expr);
 
848
    r->config_meta.check_expr = ats_strdup(record->config_meta.check_expr);
856
849
    r->config_meta.access_type = record->config_meta.access_type;
857
850
  }
858
851
 
950
943
  int num_matched = 0;
951
944
  char *result = NULL;
952
945
 
953
 
  result = (char *) xmalloc(result_size * sizeof(char));
 
946
  result = (char *)ats_malloc(result_size * sizeof(char));
954
947
  memset(result, 0, result_size * sizeof(char));
955
948
 
956
949
  int i;