/* get the length of the message */
buf_len = regerror(REG_ITOA | err, re, NULL, 0);
if (buf_len) {
- buf = (char *)emalloc(buf_len * sizeof(char));
+ buf = (char *)safe_emalloc(buf_len, sizeof(char), 0);
if (!buf) return; /* fail silently */
/* finally, get the error message */
regerror(REG_ITOA | err, re, buf, buf_len);
if (len) {
TSRMLS_FETCH();
- message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
+ message = (char *)safe_emalloc((buf_len + len + 2), sizeof(char), 0);
if (!message) {
return; /* fail silently */
}
/* start with a buffer that is twice the size of the stringo
we're doing replacements in */
buf_len = 2 * string_len + 1;
- buf = emalloc(buf_len * sizeof(char));
+ buf = safe_emalloc(buf_len, sizeof(char), 0);
err = pos = 0;
buf[0] = '\0';
new_l = strlen (buf) + 1;
if (new_l + 1 > buf_len) {
buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len * sizeof(char));
+ nbuf = safe_emalloc(buf_len, sizeof(char), 0);
strcpy(nbuf, buf);
efree(buf);
buf = nbuf;
new_l = strlen(buf) + strlen(&string[pos]);
if (new_l + 1 > buf_len) {
buf_len = new_l + 1; /* now we know exactly how long it is */
- nbuf = emalloc(buf_len * sizeof(char));
+ nbuf = safe_emalloc(buf_len, sizeof(char), 0);
strcpy(nbuf, buf);
efree(buf);
buf = nbuf;
}
convert_to_string_ex(string);
- tmp = emalloc((Z_STRLEN_PP(string) * 4) + 1);
+ tmp = safe_emalloc(Z_STRLEN_PP(string), 4, 1);
for (i = j = 0; i < Z_STRLEN_PP(string); i++) {
c = (unsigned char) Z_STRVAL_PP(string)[i];
/*-- Allocate memory for our phoned_phrase --*/
if (max_phonemes == 0) { /* Assume largest possible */
max_buffer_len = word_len;
- *phoned_word = emalloc(sizeof(char) * word_len + 1);
+ *phoned_word = safe_emalloc(sizeof(char), word_len, 1);
if (!*phoned_word)
return -1;
} else {
max_buffer_len = max_phonemes;
- *phoned_word = emalloc(sizeof(char) * max_phonemes + 1);
+ *phoned_word = safe_emalloc(sizeof(char), max_phonemes, 1);
if (!*phoned_word)
return -1;
}
WRONG_PARAM_COUNT;
}
- argv = emalloc(argc * sizeof(zval **));
+ argv = safe_emalloc(sizeof(zval **), argc, 0);
if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
efree(argv);
formatlen = Z_STRLEN_PP(argv[0]);
/* We have a maximum of <formatlen> format codes to deal with */
- formatcodes = emalloc(formatlen * sizeof(*formatcodes));
- formatargs = emalloc(formatlen * sizeof(*formatargs));
+ formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
+ formatargs = safe_emalloc(formatlen, sizeof(*formatargs), 0);
currentarg = 1;
/* Preprocess format into formatcodes and formatargs */
/* get the length of the message */
buf_len = regerror(REG_ITOA | err, re, NULL, 0);
if (buf_len) {
- buf = (char *)emalloc(buf_len * sizeof(char));
+ buf = (char *)safe_emalloc(buf_len, sizeof(char), 0);
if (!buf) return; /* fail silently */
/* finally, get the error message */
regerror(REG_ITOA | err, re, buf, buf_len);
if (len) {
TSRMLS_FETCH();
- message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
+ message = (char *)safe_emalloc((buf_len + len + 2), sizeof(char), 0);
if (!message) {
return; /* fail silently */
}
/* start with a buffer that is twice the size of the stringo
we're doing replacements in */
buf_len = 2 * string_len + 1;
- buf = emalloc(buf_len * sizeof(char));
+ buf = safe_emalloc(buf_len, sizeof(char), 0);
err = pos = 0;
buf[0] = '\0';
new_l = strlen (buf) + 1;
if (new_l + 1 > buf_len) {
buf_len = 1 + buf_len + 2 * new_l;
- nbuf = emalloc(buf_len * sizeof(char));
+ nbuf = safe_emalloc(buf_len, sizeof(char), 0);
strcpy(nbuf, buf);
efree(buf);
buf = nbuf;
new_l = strlen(buf) + strlen(&string[pos]);
if (new_l + 1 > buf_len) {
buf_len = new_l + 1; /* now we know exactly how long it is */
- nbuf = emalloc(buf_len * sizeof(char));
+ nbuf = safe_emalloc(buf_len, sizeof(char), 0);
strcpy(nbuf, buf);
efree(buf);
buf = nbuf;
}
convert_to_string_ex(string);
- tmp = emalloc((Z_STRLEN_PP(string) * 4) + 1);
+ tmp = safe_emalloc(Z_STRLEN_PP(string), 4, 1);
for (i = j = 0; i < Z_STRLEN_PP(string); i++) {
c = (unsigned char) Z_STRVAL_PP(string)[i];