Changeset 2648 for neercs


Ignore:
Timestamp:
Aug 2, 2008, 11:22:11 PM (15 years ago)
Author:
Pascal Terjan
Message:
  • Check a few more malloc, and output errors on stderr
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/configuration.c

    r2587 r2648  
    5959    {
    6060        fclose(fp);
    61         printf("Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__);
     61        fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__);
    6262        return -1;
    6363    }
     
    130130                if(!line)
    131131                {
    132                     printf("Can't allocate memory at %s:%d\n",
     132                    fprintf(stderr, "Can't allocate memory at %s:%d\n",
    133133                           __FUNCTION__, __LINE__);
    134134                    return -1;
     
    140140                if(!line)
    141141                {
    142                     printf("Can't allocate memory at %s:%d\n",
     142                    fprintf(stderr, "Can't allocate memory at %s:%d\n",
    143143                           __FUNCTION__, __LINE__);
    144144                    return -1;
     
    166166    {
    167167        struct option *option = malloc(sizeof(struct option));
     168        if(!option)
     169        {
     170            fprintf(stderr, "Can't allocate memory at %s:%d\n",
     171                   __FUNCTION__, __LINE__);
     172            return -1;
     173        }
    168174        option->next = NULL;
    169175        l-=end_spaces;
     
    196202    {
    197203        option->value = malloc(strlen(line) - 1);
     204        if(!option->value)
     205        {
     206            fprintf(stderr, "Can't allocate memory at %s:%d\n",
     207                    __FUNCTION__, __LINE__);
     208            return -1;
     209        }
    198210        memcpy(option->value, line+1, strlen(line) - 1);
    199211        option->value[strlen(line) - 2] = 0;
     
    226238            if(!cur)
    227239            {
    228                 printf("Can't allocate memory at %s:%d\n",
     240                printf(stderr, "Can't allocate memory at %s:%d\n",
    229241                       __FUNCTION__, __LINE__);
    230242            }
Note: See TracChangeset for help on using the changeset viewer.