Revision 0dbb3330 src/image/ImagePool.cc

View differences:

src/image/ImagePool.cc
89 89

  
90 90
int ImagePool::allocate (
91 91
        int            uid,
92
        const  string& stemplate,
92
        ImageTemplate* img_template,
93 93
        int *          oid)
94 94
{
95
    int     rc;
96 95
    Image * img;
97

  
98 96
    string  name;
99
    char *  error_msg;
100 97

  
101 98
    // ---------------------------------------------------------------------
102 99
    // Build a new Image object
103 100
    // ---------------------------------------------------------------------
104
    img = new Image(uid);
105

  
106
    // ---------------------------------------------------------------------
107
    // Parse template
108
    // ---------------------------------------------------------------------
109
    rc = img->image_template.parse(stemplate, &error_msg);
110

  
111
    if ( rc != 0 )
112
    {
113
        ostringstream oss;
114
        oss << "ImagePool template parse error: " << error_msg;
115
        NebulaLog::log("IMG", Log::ERROR, oss);
116

  
117
        free(error_msg);
118
        delete img;
119

  
120
        return -1;
121
    }
101
    img = new Image(uid,img_template);
122 102

  
123 103
    img->get_template_attribute("NAME", name);
124 104

  
125 105
    // ---------------------------------------------------------------------
126 106
    // Insert the Object in the pool
127 107
    // ---------------------------------------------------------------------
128

  
129 108
    *oid = PoolSQL::allocate(img);
130 109

  
131
    if ( *oid == -1 )
132
    {
133
        return -1;
134
    }
135

  
136 110
    // ---------------------------------------------------------------------
137 111
    // Add the image name to the map of image_names
138 112
    // ---------------------------------------------------------------------
139

  
140
    image_names.insert(make_pair(name, *oid));
113
    if ( *oid != -1 )
114
    {
115
        image_names.insert(make_pair(name, *oid));
116
    }
141 117

  
142 118
    return *oid;
143 119
}

Also available in: Unified diff