1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| double * a = _malloc_align( 1024, 7) // 2**7 = 128,
//petit test
if((size_t)a & 128 ) {
std::cout << " ok " << std::endl;
}else{ std::cout << " no ok " << std::endl; }
/**
Ca marche je suis content, passons à l'étape suivante, petite classe avec un peu de stl**/
//petite fonction d'alloc
void * get( size_t n){ return _malloc_align(n):}
class test
{
public:
test():ptr(NULL){}
void * ptr;
};
-------------------------------------------------------------------------
std::vector<test*> vtest(9);
std::vector<test*>::const_iterator it=vtest.begin();
for(;it != vtest.end();it++)
{
test* a = *it;
a = new test();
a->ptr = get(2048);
if((size_t)a->ptr & 128 ) {
std::cout << " ok " << std::endl;
}else{ std::cout << " no ok " << std::endl; }
} |
Partager