rname));
buf = (char *)malloc(maxwrite);
+ if (!buf) {
+ DEBUG(0, ("ERROR: Not enough memory!\n"));
+ return;
+ }
while (!feof(f)) {
int n = maxwrite;
int ret;
{
char *canonical = malloc (PATH_MAX + 1);
+ if (!canonical) {
+ fprintf(stderr, "Error! Not enough memory!\n");
+ return NULL;
+ }
+
if (strlen(path) > PATH_MAX) {
fprintf(stderr, "Mount point string too long\n");
return NULL;
maxlen += nbytes + 20 * (acl_d->count - i);
- if ((text = realloc(oldtext, maxlen)) == NULL) {
+ if ((text = Realloc(oldtext, maxlen)) == NULL) {
free(oldtext);
errno = ENOMEM;
return NULL;
for (tc=t->list; tc; tc=tc->next) {
if (tc->ptr == ptr) {
- ptr = realloc(ptr, size);
+ ptr = Realloc(ptr, size);
if (ptr) {
t->total_alloc_size += (size - tc->size);
tc->size = size;
return NULL;
}
- list = (char**)malloc(((sizeof(char**)) * P_LIST_ABS));
- if (!list) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
- free (s);
- return NULL;
- }
- memset (list, 0, ((sizeof(char**)) * P_LIST_ABS));
- lsize = P_LIST_ABS;
-
- num = 0;
+ num = lsize = 0;
+ list = NULL;
str = s;
while (*str)
{
if (!next_token(&str, tok, LIST_SEP, sizeof(pstring))) continue;
- if ((num +1) == lsize) {
+ if (num == lsize) {
lsize += P_LIST_ABS;
- rlist = (char **)realloc(list, ((sizeof(char **)) * lsize));
+ rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
if (!rlist) {
DEBUG(0,("ERROR: Unable to allocate memory"));
lp_list_free (&list);
return NULL;
}
else list = rlist;
- memset (&list[num], 0, ((sizeof(char**)) * P_LIST_ABS));
+ memset (&list[num], 0, ((sizeof(char**)) * (P_LIST_ABS +1)));
}
list[num] = strdup(tok);
*dest = NULL;
if (!src) return False;
- list = (char**)malloc(((sizeof(char**)) * P_LIST_ABS));
- if (!list) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
- return False;
- }
- memset (list, 0, ((sizeof(char**)) * P_LIST_ABS));
- lsize = P_LIST_ABS;
+ num = lsize = 0;
+ list = NULL;
- for (num = 0; src[num]; num++)
+ while (src[num])
{
- if ((num +1) == lsize) {
+ if (num == lsize) {
lsize += P_LIST_ABS;
- rlist = (char **)realloc(list, ((sizeof(char **)) * lsize));
+ rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
if (!rlist) {
DEBUG(0,("ERROR: Unable to allocate memory"));
lp_list_free (&list);
return False;
}
else list = rlist;
- memset (&list[num], 0, ((sizeof(char**)) * P_LIST_ABS));
+ memset (&list[num], 0, ((sizeof(char **)) * (P_LIST_ABS +1)));
}
list[num] = strdup(src[num]);
lp_list_free (&list);
return False;
}
+
+ num++;
}
*dest = list;
return True;
}
-
if (mods[i] == NULL)
{
- mods = (LDAPMod **)realloc( mods, (i+2) * sizeof( LDAPMod * ) );
+ mods = (LDAPMod **)Realloc( mods, (i+2) * sizeof( LDAPMod * ) );
if (mods == NULL)
{
DEBUG(0,("make_a_mod: out of memory!\n"));
{
for ( ; mods[ i ]->mod_values[ j ] ! = NULL; j++ );
}
- mods[ i ]->mod_values = (char **)realloc(mods[ i ]->mod_values,
+ mods[ i ]->mod_values = (char **)Realloc(mods[ i ]->mod_values,
(j+2) * sizeof( char * ));
if ( mods[ i ]->mod_values == NULL)
{
{
qalloc += 16;
- if (qalloc == 16)
- temp = malloc(sizeof(print_queue_struct) * qalloc);
- else
- temp = realloc(queue, sizeof(print_queue_struct) * qalloc);
+ temp = Realloc(queue, sizeof(print_queue_struct) * qalloc);
if (temp == NULL)
{
+ DEBUG(0,("cups_queue_get: Not enough memory!");
ippDelete(response);
httpClose(http);
- return (qcount);
+ free (queue);
+ return (0);
}
queue = temp;
DEBUG(0,("Unable to get printer status for %s - %s\n", PRINTERNAME(snum),
ippErrorString(cupsLastError())));
httpClose(http);
+ *q = queue;
return (qcount);
}
ippErrorString(response->request.status.status_code)));
ippDelete(response);
httpClose(http);
-
+ *q = queue;
return (qcount);
}
static char *grab_line(FILE *f, int *cl)
{
- char *ret;
+ char *ret = NULL;
int i = 0;
int len = 1024;
- ret = (char *)malloc(len);
- if (!ret) return NULL;
-
-
while ((*cl)) {
- int c = fgetc(f);
+ int c;
+
+ if (i == len) {
+ char *ret2;
+ if (len == 0) len = 1024;
+ else len *= 2;
+ ret2 = (char *)Realloc(ret, len*2);
+ if (!ret2) return ret;
+ ret = ret2;
+ }
+
+ c = fgetc(f);
(*cl)--;
if (c == EOF) {
ret[i++] = c;
- if (i == len-1) {
- char *ret2;
- ret2 = (char *)realloc(ret, len*2);
- if (!ret2) return ret;
- len *= 2;
- ret = ret2;
- }
}