Revision ca2a1a42 src/host/HostPool.cc

View differences:

src/host/HostPool.cc
145 145
/* -------------------------------------------------------------------------- */
146 146
/* -------------------------------------------------------------------------- */
147 147

  
148
HostPool::~HostPool()
149
{
150
    map<int, HostVM *>::iterator it;
151

  
152
    for (it=host_vms.begin(); it != host_vms.end() ; ++it)
153
    {
154
        delete it->second;
155
    } 
156
};
157

  
158
/* -------------------------------------------------------------------------- */
159
/* -------------------------------------------------------------------------- */
160

  
148 161
int HostPool::allocate (
149 162
    int * oid,
150 163
    const string& hostname,
......
322 335

  
323 336
    return rc;
324 337
}
338

  
339
/* -------------------------------------------------------------------------- */
340
/* -------------------------------------------------------------------------- */
341

  
342
HostPool::HostVM * HostPool::get_host_vm(int oid)
343
{
344
    HostVM * hvm;
345

  
346
    map<int, HostVM *>::iterator it = host_vms.find(oid);
347

  
348
    if ( it == host_vms.end() )
349
    {
350
        hvm = new HostVM;
351

  
352
        host_vms.insert(make_pair(oid, new HostVM));
353
    }
354
    else
355
    {
356
        hvm = it->second;
357
    }
358

  
359
    return hvm;
360
}
361

  
362
void HostPool::delete_host_vm(int oid)
363
{
364
    HostVM * hvm;
365

  
366
    map<int, HostVM *>::iterator it = host_vms.find(oid);
367

  
368
    if ( it != host_vms.end() )
369
    {
370
        delete it->second;
371

  
372
        host_vms.erase(it);
373
    }
374
}
375

  

Also available in: Unified diff