BlinkenArea - GitList
Repositories
Blog
Wiki
BlinkenLib
Code
Commits
Branches
Tags
Search
Tree:
457e484
Branches
Tags
master
v0.1
v0.2
v0.3
v0.3.1
v0.4
v0.4.1
v0.5
v0.5.1
v0.5.2
v0.5.3
v0.5.4
v0.5.5
v0.6.0
v0.6.1
v0.6.2
v0.6.3
v0.6.4
v0.6.5
v0.6.6
v0.6.7
v0.6.8
v0.6.9
v0.7.0
v0.7.1
v0.7.10
v0.7.2
v0.7.3
v0.7.4
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.7.9
v0.8.0
v0.8.1
BlinkenLib
Tools.c
BlinkenLib v.0.3 (2005-02-16)
Christian Heimke
commited
457e484
at 2011-07-15 09:01:49
Tools.c
Blame
History
Raw
/* BlinkenLib * version 0.3 date 2005-02-16 * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html * a blinkenarea.org project * powered by eventphone.de */ #include <stdlib.h> #include "Tools.h" void * malloc1D( int count1, int size ) { if( count1 < 1 ) count1 = 1; if( size < 1 ) return NULL; return malloc( count1 * size ); } void * * malloc2D( int count1, int count2, int size ) { int sz, i; char * p; void * * ptr; if( count1 < 1 ) count1 = 1; if( count2 < 1 ) count2 = 1; if( size < 1 ) return NULL; sz = count1 * sizeof( void * ) + count1 * count2 * size; p = (char *)malloc( sz ); if( p == NULL ) return NULL; ptr = (void * *)p; p += count1 * sizeof( void * ); for( i = 0; i < count1; i++ ) { ptr[i] = (void *)p; p += count2 * size; } return ptr; } void * * * malloc3D( int count1, int count2, int count3, int size ) { int sz, i, j; char * p; void * * * ptr; if( count1 < 1 ) count1 = 1; if( count2 < 1 ) count2 = 1; if( count3 < 1 ) count3 = 1; if( size < 1 ) return NULL; sz = count1 * sizeof( void * * ) + count1 * count2 * sizeof( void * ) + count1 * count2 * count3 * size; p = (char *)malloc( sz ); if( p == NULL ) return NULL; ptr = (void * * *)p; p += count1 * sizeof( void * * ); for( i = 0; i < count1; i++ ) { ptr[i] = (void * *)p; p += count2 * sizeof( void * ); } for( i = 0; i < count1; i++ ) for( j = 0; j < count2; j++ ) { ptr[i][j] = (void *)p; p += count3 * size; } return ptr; }