[ create a new paste ] login | about

Link: http://codepad.org/eOTHWotX    [ raw code | fork ]

joel_f - C++, pasted on Jun 20:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template<class T> static inline T** alloc( size_t h, size_t w )
{
  typedef T* ptr_type;
  ptr_type* m;
  m    = new ptr_type[h];
  m[0] = new T[h*w];
  for(size_t i=1;i<h;i++) m[i]=m[i-1]+w;
  return m;
}

template<class T> static inline void release( T** ptr )
{
  if(ptr) delete[] ptr[0];
  if(ptr) delete[] ptr;
}

int main()
{

}


Output:
No errors or program output.


Create a new paste based on this one


Comments: