#include "../include/Segment.h"

namespace environment {
namespace data {
  
  bool Segment::init (const char * filename,const char ** sections)
  {
    void * ptab;
    int    size   = this->size;
    int    offset = 0;
    
    loadexec(&ptab,&size,&offset,filename,sections);
    
//     std::cout << "    - size         : " << size         << std::endl;
//     std::cout << "    - offset       : " << offset       << std::endl;
    
    if (size > (int)this->size)
      {
	std::cerr << "<segment.init> : segment \"" << name << "\" is to small : size is " << this->size << " and requiert is " << size << std::endl;
	return false;
      }
    
    memcpy(data, ptab, size);
    
    free  (ptab);
    
    return true;
  }
  
};
};
