diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds.h b/src/osgPlugins/3ds/lib3ds/lib3ds.h index e3f4d171f..7026418dc 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds.h +++ b/src/osgPlugins/3ds/lib3ds/lib3ds.h @@ -4,30 +4,31 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include +#include #ifndef LIB3DSAPI #if defined(_MSC_VER) && !defined(LIB3DS_STATIC) #ifdef LIB3DS_EXPORTS #define LIB3DSAPI __declspec(dllexport) - #else + #else #define LIB3DSAPI __declspec(dllimport) - #endif + #endif #else #define LIB3DSAPI #endif @@ -40,6 +41,11 @@ extern "C" { /** @defgroup api API */ /** @{ */ +extern void stringcopy(char* dest, const char* src, size_t length); + +#define stringcopyfixedsize(DEST, SRC) stringcopy(DEST, SRC, sizeof(DEST)); + + typedef enum Lib3dsIoSeek { LIB3DS_SEEK_SET = 0, LIB3DS_SEEK_CUR = 1, @@ -208,17 +214,17 @@ typedef struct Lib3dsTextureMap { typedef enum Lib3dsAutoReflMapFlags { LIB3DS_AUTOREFL_USE = 0x0001, LIB3DS_AUTOREFL_READ_FIRST_FRAME_ONLY = 0x0004, - LIB3DS_AUTOREFL_FLAT_MIRROR = 0x0008 + LIB3DS_AUTOREFL_FLAT_MIRROR = 0x0008 } Lib3dsAutoReflMapFlags; /* Material shading type */ typedef enum Lib3dsShading { LIB3DS_SHADING_WIRE_FRAME = 0, - LIB3DS_SHADING_FLAT = 1, - LIB3DS_SHADING_GOURAUD = 2, - LIB3DS_SHADING_PHONG = 3, + LIB3DS_SHADING_FLAT = 1, + LIB3DS_SHADING_GOURAUD = 2, + LIB3DS_SHADING_PHONG = 3, LIB3DS_SHADING_METAL = 4 -} Lib3dsShading; +} Lib3dsShading; /** Material */ typedef struct Lib3dsMaterial { @@ -242,7 +248,7 @@ typedef struct Lib3dsMaterial { int soften; /* bool */ int face_map; /* bool */ int two_sided; /* Material visible from back */ - int transparency_falloff; /* Transparency falloff in/out */ + int transparency_falloff; /* Transparency falloff in/out */ int map_decal; /* bool */ int use_wire; int use_wire_abs; @@ -271,13 +277,13 @@ typedef struct Lib3dsMaterial { /** Object flags for cameras, lights and meshes */ typedef enum Lib3dsObjectFlags { - LIB3DS_OBJECT_HIDDEN = 0x01, - LIB3DS_OBJECT_VIS_LOFTER = 0x02, - LIB3DS_OBJECT_DOESNT_CAST = 0x04, - LIB3DS_OBJECT_MATTE = 0x08, - LIB3DS_OBJECT_DONT_RCVSHADOW = 0x10, - LIB3DS_OBJECT_FAST = 0x20, - LIB3DS_OBJECT_FROZEN = 0x40 + LIB3DS_OBJECT_HIDDEN = 0x01, + LIB3DS_OBJECT_VIS_LOFTER = 0x02, + LIB3DS_OBJECT_DOESNT_CAST = 0x04, + LIB3DS_OBJECT_MATTE = 0x08, + LIB3DS_OBJECT_DONT_RCVSHADOW = 0x10, + LIB3DS_OBJECT_FAST = 0x20, + LIB3DS_OBJECT_FROZEN = 0x40 } Lib3dsObjectFlags; /** Camera object */ @@ -285,7 +291,7 @@ typedef struct Lib3dsCamera { unsigned user_id; void* user_ptr; char name[64]; - unsigned object_flags; /*< @see Lib3dsObjectFlags */ + unsigned object_flags; /*< @see Lib3dsObjectFlags */ float position[3]; float target[3]; float roll; @@ -293,14 +299,14 @@ typedef struct Lib3dsCamera { int see_cone; float near_range; float far_range; -} Lib3dsCamera; +} Lib3dsCamera; /** Light object */ typedef struct Lib3dsLight { unsigned user_id; void* user_ptr; char name[64]; - unsigned object_flags; + unsigned object_flags; int spot_light; /* bool */ int see_cone; float color[3]; @@ -326,7 +332,7 @@ typedef struct Lib3dsLight { float ray_bias; float hotspot; float falloff; -} Lib3dsLight; +} Lib3dsLight; /* Texture map projection */ typedef enum { @@ -336,7 +342,7 @@ typedef enum { LIB3DS_MAP_SPHERICAL = 2 } Lib3dsMapType; -/** Meaning of Lib3dsFace::flags. ABC are points of the current face +/** Meaning of Lib3dsFace::flags. ABC are points of the current face (A: is 1st vertex, B is 2nd vertex, C is 3rd vertex) */ typedef enum Lib3dsFaceFlags { LIB3DS_FACE_VIS_AC = 0x01, /**< Bit 0: Edge visibility AC */ @@ -354,14 +360,14 @@ typedef struct Lib3dsFace { unsigned short flags; int material; unsigned smoothing_group; -} Lib3dsFace; +} Lib3dsFace; /* Triangular mesh object */ typedef struct Lib3dsMesh { unsigned user_id; void* user_ptr; char name[64]; /**< Mesh name. Don't use more than 8 characters */ - unsigned object_flags; /**< @see Lib3dsObjectFlags */ + unsigned object_flags; /**< @see Lib3dsObjectFlags */ int color; /**< Index to editor palette [0..255] */ float matrix[4][4]; /**< Transformation matrix for mesh data */ unsigned short nvertices; /**< Number of vertices in vertex array (max. 65535) */ @@ -369,7 +375,7 @@ typedef struct Lib3dsMesh { float (*texcos)[2]; unsigned short* vflags; unsigned short nfaces; /**< Number of faces in face array (max. 65535) */ - Lib3dsFace* faces; + Lib3dsFace* faces; char box_front[64]; char box_back[64]; char box_left[64]; @@ -383,7 +389,7 @@ typedef struct Lib3dsMesh { float map_tile[2]; float map_planar_size[2]; float map_cylinder_height; -} Lib3dsMesh; +} Lib3dsMesh; typedef enum Lib3dsNodeType { LIB3DS_NODE_AMBIENT_COLOR = 0, @@ -455,9 +461,9 @@ typedef enum { typedef struct Lib3dsTrack { unsigned flags; - Lib3dsTrackType type; + Lib3dsTrackType type; int nkeys; - Lib3dsKey* keys; + Lib3dsKey* keys; } Lib3dsTrack; typedef struct Lib3dsAmbientColorNode { @@ -541,19 +547,19 @@ typedef struct Lib3dsFile { int segment_to; int current_frame; int materials_size; - int nmaterials; - Lib3dsMaterial** materials; - int cameras_size; - int ncameras; + int nmaterials; + Lib3dsMaterial** materials; + int cameras_size; + int ncameras; Lib3dsCamera** cameras; int lights_size; - int nlights; + int nlights; Lib3dsLight** lights; int meshes_size; - int nmeshes; - Lib3dsMesh** meshes; + int nmeshes; + Lib3dsMesh** meshes; Lib3dsNode* nodes; -} Lib3dsFile; +} Lib3dsFile; extern LIB3DSAPI Lib3dsFile* lib3ds_file_open(const char *filename); extern LIB3DSAPI int lib3ds_file_save(Lib3dsFile *file, const char *filename); @@ -589,7 +595,7 @@ extern LIB3DSAPI void lib3ds_file_create_nodes_for_meshes(Lib3dsFile *file); /** - This function computes the bounding box of meshes, cameras + This function computes the bounding box of meshes, cameras and lights defined in the 3D editor. \param file The Lib3dsFile object to be examined. @@ -600,17 +606,17 @@ extern LIB3DSAPI void lib3ds_file_create_nodes_for_meshes(Lib3dsFile *file); \param bmax Returned maximum x,y,z values. */ extern LIB3DSAPI void lib3ds_file_bounding_box_of_objects( - Lib3dsFile *file, - int include_meshes, + Lib3dsFile *file, + int include_meshes, int include_cameras, int include_lights, float bmin[3], float bmax[3]); /** - This function computes the bounding box of mesh, camera + This function computes the bounding box of mesh, camera and light instances defined in the Keyframer. - + \param file The Lib3dsFile object to be examined. \param include_meshes Include meshes in bounding box calculation. \param include_cameras Include cameras in bounding box calculation. @@ -621,12 +627,12 @@ extern LIB3DSAPI void lib3ds_file_bounding_box_of_objects( calculate the bounding box in. */ extern LIB3DSAPI void lib3ds_file_bounding_box_of_nodes( - Lib3dsFile *file, - int include_meshes, - int include_cameras, - int include_lights, - float bmin[3], - float bmax[3], + Lib3dsFile *file, + int include_meshes, + int include_cameras, + int include_lights, + float bmin[3], + float bmax[3], float matrix[4][4]); extern LIB3DSAPI Lib3dsMaterial* lib3ds_material_new(const char *name); @@ -664,13 +670,13 @@ extern LIB3DSAPI void lib3ds_track_eval_float(Lib3dsTrack *track, float *f, floa extern LIB3DSAPI void lib3ds_track_eval_vector(Lib3dsTrack *track, float v[3], float t); extern LIB3DSAPI void lib3ds_track_eval_quat(Lib3dsTrack *track, float q[4], float t); -/** - Calculates the ease in/out function. See Lib3dsKey for details. - +/** + Calculates the ease in/out function. See Lib3dsKey for details. + \param fp Previous frame number. \param fc Current frame number. - \param fn Next frame number. - \param ease_from Ease in value [0, 1.0] + \param fn Next frame number. + \param ease_from Ease in value [0, 1.0] \param ease_to Ease out value [0, 1.0] */ extern LIB3DSAPI float lib3ds_math_ease( @@ -680,13 +686,13 @@ extern LIB3DSAPI float lib3ds_math_ease( float ease_from, float ease_to); -/** - Computes a point on a n-dimensional cubic hermite spline. - \param v - [out] Result +/** + Computes a point on a n-dimensional cubic hermite spline. + \param v + [out] Result \param a [in] First point of the spline. - \param p + \param p [in] Tangent at the first point of the spline. \param q [in] Tangent at the second point of the spline. @@ -695,10 +701,10 @@ extern LIB3DSAPI float lib3ds_math_ease( \param n [in] Dimension \param t - [in] Parameter value [0...1] + [in] Parameter value [0...1] */ extern LIB3DSAPI void lib3ds_math_cubic_interp( - float *v, + float *v, float *a, float *p, float *q, @@ -712,27 +718,27 @@ extern LIB3DSAPI void lib3ds_vector_make( float y, float z); -/** - Sets all components of a vector to zero. +/** + Sets all components of a vector to zero. \param c The Pointer to the vector. */ extern LIB3DSAPI void lib3ds_vector_zero( float c[3]); -/** - Copies all components of a vector to another vector. +/** + Copies all components of a vector to another vector. \param dst [out] The destination vector. \param src [in] The source vector. */ -extern LIB3DSAPI void lib3ds_vector_copy( - float dst[3], +extern LIB3DSAPI void lib3ds_vector_copy( + float dst[3], float src[3]); -/** - Negates all components of a vector. +/** + Negates all components of a vector. \param c The Pointer to the vector. */ diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_camera.c b/src/osgPlugins/3ds/lib3ds/lib3ds_camera.c index 24a753c33..c79715aa5 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_camera.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_camera.c @@ -1,19 +1,19 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include "lib3ds_impl.h" @@ -39,7 +39,7 @@ lib3ds_camera_new(const char *name) { if (!camera) { return(0); } - strcpy(camera->name, name); + stringcopyfixedsize(camera->name, name); camera->fov = 45.0f; return(camera); } diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_light.c b/src/osgPlugins/3ds/lib3ds/lib3ds_light.c index 939b220a6..1c439e97d 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_light.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_light.c @@ -1,19 +1,19 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include "lib3ds_impl.h" @@ -29,7 +29,7 @@ lib3ds_light_new(const char *name) { if (!light) { return(0); } - strcpy(light->name, name); + stringcopyfixedsize(light->name, name); return(light); } @@ -59,7 +59,7 @@ spotlight_read(Lib3dsLight *light, Lib3dsIo *io) { while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) { switch (chunk) { - case CHK_DL_SPOT_ROLL: + case CHK_DL_SPOT_ROLL: light->roll = lib3ds_io_read_float(io); break; @@ -145,19 +145,19 @@ lib3ds_light_read(Lib3dsLight *light, Lib3dsIo *io) { break; } - case CHK_DL_OFF: + case CHK_DL_OFF: light->off = TRUE; break; - case CHK_DL_OUTER_RANGE: + case CHK_DL_OUTER_RANGE: light->outer_range = lib3ds_io_read_float(io); break; - case CHK_DL_INNER_RANGE: + case CHK_DL_INNER_RANGE: light->inner_range = lib3ds_io_read_float(io); break; - case CHK_DL_MULTIPLIER: + case CHK_DL_MULTIPLIER: light->multiplier = lib3ds_io_read_float(io); break; @@ -167,7 +167,7 @@ lib3ds_light_read(Lib3dsLight *light, Lib3dsIo *io) { break; } - case CHK_DL_ATTENUATE: + case CHK_DL_ATTENUATE: light->attenuation = lib3ds_io_read_float(io); break; diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_material.c b/src/osgPlugins/3ds/lib3ds/lib3ds_material.c index d3ed4988b..010b8e56f 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_material.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_material.c @@ -1,23 +1,22 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include "lib3ds_impl.h" - static void initialize_texture_map(Lib3dsTextureMap *map) { map->flags = 0x10; @@ -45,7 +44,7 @@ lib3ds_material_new(const char* name) { } if (name) { - strcpy(mat->name, name); + stringcopyfixedsize(mat->name, name); } mat->ambient[0] = mat->ambient[1] = mat->ambient[2] = 0.588235f; mat->diffuse[0] = mat->diffuse[1] = mat->diffuse[2] = 0.588235f; @@ -190,7 +189,7 @@ texture_map_read(Lib3dsTextureMap *map, Lib3dsIo *io) { break; } - case CHK_MAT_MAP_TEXBLUR: + case CHK_MAT_MAP_TEXBLUR: map->blur = lib3ds_io_read_float(io); break; @@ -497,7 +496,7 @@ lib3ds_material_read(Lib3dsMaterial *material, Lib3dsIo *io) { material->autorefl_map_frame_step = lib3ds_io_read_intd(io); break; } - + default: lib3ds_chunk_unknown(chunk, io); } diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_mesh.c b/src/osgPlugins/3ds/lib3ds/lib3ds_mesh.c index df2157a23..99f340003 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_mesh.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_mesh.c @@ -1,19 +1,19 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include "lib3ds_impl.h" @@ -41,7 +41,7 @@ lib3ds_mesh_new(const char *name) { if (!mesh) { return (0); } - strcpy(mesh->name, name); + stringcopyfixedsize(mesh->name, name); lib3ds_matrix_identity(mesh->matrix); mesh->map_type = LIB3DS_MAP_NONE; return (mesh); @@ -67,22 +67,22 @@ lib3ds_mesh_resize_vertices(Lib3dsMesh *mesh, int nvertices, int use_texcos, int assert(mesh); mesh->vertices = (float (*)[3])lib3ds_util_realloc_array(mesh->vertices, mesh->nvertices, nvertices, 3 * sizeof(float)); mesh->texcos = (float (*)[2])lib3ds_util_realloc_array( - mesh->texcos, - mesh->texcos? mesh->nvertices : 0, - use_texcos? nvertices : 0, + mesh->texcos, + mesh->texcos? mesh->nvertices : 0, + use_texcos? nvertices : 0, 2 * sizeof(float) ); mesh->vflags = (unsigned short*)lib3ds_util_realloc_array( - mesh->vflags, - mesh->vflags? mesh->nvertices : 0, - use_flags? nvertices : 0, + mesh->vflags, + mesh->vflags? mesh->nvertices : 0, + use_flags? nvertices : 0, 2 * sizeof(float) ); mesh->nvertices = (unsigned short)nvertices; } -void +void lib3ds_mesh_resize_faces(Lib3dsMesh *mesh, int nfaces) { int i; assert(mesh); @@ -186,7 +186,7 @@ lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float (*normals)[3]) { lib3ds_vector_sub(q, mesh->vertices[mesh->faces[i].index[j>0? j - 1 : 2]], mesh->vertices[mesh->faces[i].index[j]]); lib3ds_vector_cross(n, p, q); len = lib3ds_vector_length(n); - if (len > 0) { + if (len > 0) { weight = (float)atan2(len, lib3ds_vector_dot(p, q)); lib3ds_vector_scalar_mul(l->normal, n, weight / len); } else { @@ -215,7 +215,7 @@ lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float (*normals)[3]) { } for (p = fl[mesh->faces[i].index[j]]; p; p = p->next) { - pf = &mesh->faces[p->index]; + pf = &mesh->faces[p->index]; if (smoothing_group & pf->smoothing_group) { lib3ds_vector_add(n, n, p->normal); } @@ -594,7 +594,7 @@ texco_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) { if (!mesh->texcos) { return; } - + c.chunk = CHK_TEX_VERTS; c.size = 8 + 8 * mesh->nvertices; lib3ds_chunk_write(&c, io); @@ -669,7 +669,7 @@ lib3ds_mesh_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io) { lib3ds_chunk_write(&c, io); lib3ds_io_write_byte(io, (uint8_t)mesh->color); } - + face_array_write(file, mesh, io); lib3ds_chunk_write_end(&c, io); diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_node.c b/src/osgPlugins/3ds/lib3ds/lib3ds_node.c index d5bc025ea..61e3517f1 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_node.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_node.c @@ -138,7 +138,7 @@ lib3ds_node_new_mesh_instance(Lib3dsMesh *mesh, const char *instance_name, float n = (Lib3dsMeshInstanceNode*)node; if (instance_name) { - strcpy(n->instance_name, instance_name); + stringcopyfixedsize(n->instance_name, instance_name); } lib3ds_track_resize(&n->pos_track, 1); diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_util.c b/src/osgPlugins/3ds/lib3ds/lib3ds_util.c index 60369a7a1..bc5139c4a 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_util.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_util.c @@ -1,23 +1,30 @@ /* Copyright (C) 1996-2008 by Jan Eric Kyprianidis All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation, either version 2.1 of the License, or + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. - Thisprogram is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Thisprogram is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License - along with this program; If not, see . + along with this program; If not, see . */ #include "lib3ds_impl.h" +void stringcopy(char* dest, const char* src, size_t length) +{ + strncpy(dest, src, length-1); + dest[length-1] = '\0'; +} + + void* lib3ds_util_realloc_array(void *ptr, int old_size, int new_size, int element_size) { if (!ptr) old_size = 0;