--- /dev/null
+/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r
+ * This file is part of clib library\r
+ * Copyright (C) 2011 Avinash Dongre ( dongre.avinash@gmail.com )\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy\r
+ * of this software and associated documentation files (the "Software"), to deal\r
+ * in the Software without restriction, including without limitation the rights\r
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+ * copies of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/\r
+\r
+#include "c_lib.h"\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+void \r
+clib_copy( void *destination, void *source, size_t size ) {\r
+ memcpy ( (char*)destination, source, size);\r
+}\r
+void\r
+clib_get ( void *destination, void *source, size_t size) {\r
+ memcpy ( destination, (char*)source, size);\r
+}\r
+\r
+struct clib_object*\r
+new_clib_object(void *inObject, size_t obj_size) {\r
+ struct clib_object* tmp = (struct clib_object*)malloc(sizeof(struct clib_object)); \r
+ if ( ! tmp )\r
+ return (struct clib_object*)0;\r
+ tmp->size = obj_size;\r
+ tmp->raw_data = (void*)malloc(obj_size);\r
+ if ( !tmp->raw_data ) {\r
+ free ( tmp );\r
+ return (struct clib_object*)0;\r
+ }\r
+ memcpy ( tmp->raw_data, inObject, obj_size);\r
+ return tmp;\r
+}\r
+\r
+clib_error\r
+get_raw_clib_object ( struct clib_object *inObject, void**elem) {\r
+ *elem = (void*)malloc(inObject->size);\r
+ if ( ! *elem )\r
+ return CLIB_ELEMENT_RETURN_ERROR;\r
+ memcpy ( *elem, inObject->raw_data, inObject->size );\r
+\r
+ return CLIB_ERROR_SUCCESS;\r
+}\r
+void \r
+replace_raw_clib_object(struct clib_object *current_object,void *elem, size_t elem_size) {\r
+ free (current_object->raw_data);\r
+ current_object->raw_data = (void*)malloc(elem_size);\r
+ memcpy ( current_object->raw_data, elem, elem_size);\r
+}\r
+\r
+\r
+void \r
+delete_clib_object ( struct clib_object *inObject ) {\r
+ if (inObject) {\r
+ free (inObject->raw_data);\r
+ free (inObject);\r
+ }\r
+}\r
+\r
+char*\r
+clib_strdup ( char *ptr ) {\r
+ #ifdef WIN32\r
+ return _strdup (ptr);\r
+ #else\r
+ return strdup (ptr);\r
+ #endif\r
+}\r