Ported picomodel.c from 1.5

Improvements over 1.4/1.5 are in.
This commit is contained in:
Christophe Mateos 2016-12-04 01:43:28 +01:00
parent 3fb0a994e2
commit 41f9d3a1e1
4 changed files with 593 additions and 222 deletions

View file

@ -105,6 +105,7 @@ struct picoSurface_s
int numVertexes, maxVertexes;
picoVec3_t *xyz;
picoVec3_t *normal;
picoIndex_t *smoothingGroup;
int numSTArrays, maxSTArrays;
picoVec2_t **st;
@ -216,6 +217,9 @@ const picoModule_t **PicoModuleList( int *numModules );
picoModel_t *PicoLoadModel( char *name, int frameNum );
typedef size_t(*PicoInputStreamReadFunc)(void* inputStream, unsigned char* buffer, size_t length);
picoModel_t* PicoModuleLoadModelStream(const picoModule_t* module, void* inputStream, PicoInputStreamReadFunc inputStreamRead, size_t streamLength, int frameNum);
/* model functions */
picoModel_t *PicoNewModel( void );

View file

@ -161,35 +161,22 @@ void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize ){
* as custom clone size (the string is cropped to fit into mem
* if needed). -sea
*/
char *_pico_clone_alloc( char *str, int size ){
char *cloned;
size_t cloneSize;
char *_pico_clone_alloc(const char *str)
{
char* cloned;
/* sanity check */
if ( str == NULL ) {
if (str == NULL)
return NULL;
}
/* set real size of cloned string */
cloneSize = ( size < 0 ) ? strlen( str ) : size;
/* allocate memory */
cloned = _pico_alloc( cloneSize + 1 ); /* bugfix! */
if ( cloned == NULL ) {
cloned = _pico_alloc(strlen(str) + 1);
if (cloned == NULL)
return NULL;
}
/* zero out memory allocated by cloned string */
memset( cloned,0,cloneSize );
/* copy input string to cloned string */
if ( cloneSize < strlen( str ) ) {
memcpy( cloned,str,cloneSize );
cloned[ cloneSize ] = '\0';
}
else {
strcpy( cloned,str );
}
strcpy(cloned, str);
/* return ptr to cloned string */
return cloned;
}

View file

@ -116,7 +116,7 @@ extern void ( *_pico_ptr_print )( int, const char* );
void *_pico_alloc( size_t size );
void *_pico_calloc( size_t num, size_t size );
void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize );
char *_pico_clone_alloc( char *str, int size );
char *_pico_clone_alloc( char *str/*, int size*/ );
void _pico_free( void *ptr );
/* files */

File diff suppressed because it is too large Load diff