opennurbs_memory_util.c
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs_system.h"
00018 #include "pcl/surface/3rdparty/opennurbs/opennurbs_defines.h"
00019 #include "pcl/surface/3rdparty/opennurbs/opennurbs_memory.h"
00020 
00021 // Memory utilities used by OpenNURBS.  If you are using
00022 // custom memory managment, NOTHING in this file needs to
00023 // be changed.
00024 
00025 
00026 void* onmemdup( const void* src, size_t sz )
00027 {
00028   void* p;
00029   if ( src && sz>0 ) 
00030   {
00031     p = onmalloc(sz);
00032     if (p)
00033       memcpy(p,src,sz);
00034   }
00035   else {
00036     p = 0;
00037   }
00038   return p;
00039 }
00040 
00041 
00042 char* onstrdup( const char* src )
00043 {
00044   char* p;
00045   size_t sz;
00046   if ( src ) 
00047   {
00048     for ( sz=0;*src++;sz++)
00049       ; /* empty for body */
00050     sz++;
00051     p = (char*)onmemdup( src-sz, sz*sizeof(*src) );
00052   }
00053   else 
00054   {
00055     p = 0;
00056   }
00057   return p;
00058 }
00059 
00060 
00061 unsigned char* onmbsdup( const unsigned char* src )
00062 {
00063   unsigned char* p;
00064   size_t sz; /* sz = number of bytes to dup (>=_mbclen(scr)) */
00065   if ( src ) 
00066   {
00067     for ( sz=0;*src++;sz++)
00068       ; /* empty for body */
00069     sz++;
00070     p = (unsigned char*)onmemdup( src-sz, sz*sizeof(*src) );
00071   }
00072   else 
00073   {
00074     p = 0;
00075   }
00076   return p;
00077 }
00078 
00079 #if defined(_WCHAR_T_DEFINED)
00080 
00081 wchar_t* onwcsdup( const wchar_t* src )
00082 {
00083   wchar_t* p;
00084   size_t sz;
00085   if ( src ) 
00086   {
00087     for ( sz=0;*src++;sz++)
00088       ; /* empty for body */
00089     sz++;
00090     p = (wchar_t*)onmemdup( src-sz, sz*sizeof(*src) );
00091   }
00092   else 
00093   {
00094     p = 0;
00095   }
00096   return p;
00097 }
00098 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:01