Move some utility functions to slang_utility.c.
authorMichal Krol <mjkrol@gmail.org>
Fri, 22 Apr 2005 10:15:32 +0000 (10:15 +0000)
committerMichal Krol <mjkrol@gmail.org>
Fri, 22 Apr 2005 10:15:32 +0000 (10:15 +0000)
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_utility.c [new file with mode: 0644]
src/mesa/shader/slang/slang_utility.h [new file with mode: 0644]
src/mesa/sources

index 5ecef00..d49d104 100644 (file)
@@ -29,8 +29,9 @@
  */
 
 #include "imports.h" 
-#include "slang_compile.h"
 #include "grammar_mesa.h"
+#include "slang_utility.h"
+#include "slang_compile.h"
 #include "slang_preprocess.h"
 
 /*
        may be accepted resulting in undefined behaviour.
 */
 
-void slang_alloc_free (void *ptr)
-{
-       _mesa_free (ptr);
-}
-
-void *slang_alloc_malloc (unsigned int size)
-{
-       return _mesa_malloc (size);
-}
-
-void *slang_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
-{
-       return _mesa_realloc (ptr, old_size, size);
-}
-
-int slang_string_compare (const char *str1, const char *str2)
-{
-       return _mesa_strcmp (str1, str2);
-}
-
-char *slang_string_copy (char *dst, const char *src)
-{
-       return _mesa_strcpy (dst, src);
-}
-
-char *slang_string_concat (char *dst, const char *src)
-{
-       return _mesa_strcpy (dst + _mesa_strlen (dst), src);
-}
-
-char *slang_string_duplicate (const char *src)
-{
-       return _mesa_strdup (src);
-}
-
-unsigned int slang_string_length (const char *str)
-{
-       return _mesa_strlen (str);
-}
-
 static void slang_variable_construct (slang_variable *);
 static int slang_variable_copy (slang_variable *, const slang_variable *);
 static void slang_struct_construct (slang_struct *);
diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c
new file mode 100644 (file)
index 0000000..c07e161
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.3\r
+ *\r
+ * Copyright (C) 2005  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/**\r
+ * \file slang_utility.c\r
+ * slang utilities\r
+ * \author Michal Krol\r
+ */\r
+\r
+#include "imports.h"\r
+#include "slang_utility.h"\r
+\r
+void slang_alloc_free (void *ptr)\r
+{\r
+       _mesa_free (ptr);\r
+}\r
+\r
+void *slang_alloc_malloc (unsigned int size)\r
+{\r
+       return _mesa_malloc (size);\r
+}\r
+\r
+void *slang_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)\r
+{\r
+       return _mesa_realloc (ptr, old_size, size);\r
+}\r
+\r
+int slang_string_compare (const char *str1, const char *str2)\r
+{\r
+       return _mesa_strcmp (str1, str2);\r
+}\r
+\r
+char *slang_string_copy (char *dst, const char *src)\r
+{\r
+       return _mesa_strcpy (dst, src);\r
+}\r
+\r
+char *slang_string_concat (char *dst, const char *src)\r
+{\r
+       return _mesa_strcpy (dst + _mesa_strlen (dst), src);\r
+}\r
+\r
+char *slang_string_duplicate (const char *src)\r
+{\r
+       return _mesa_strdup (src);\r
+}\r
+\r
+unsigned int slang_string_length (const char *str)\r
+{\r
+       return _mesa_strlen (str);\r
+}\r
+\r
diff --git a/src/mesa/shader/slang/slang_utility.h b/src/mesa/shader/slang/slang_utility.h
new file mode 100644 (file)
index 0000000..6eb5369
--- /dev/null
@@ -0,0 +1,46 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.3\r
+ *\r
+ * Copyright (C) 2005  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+#if !defined SLANG_UTILITY_H\r
+#define SLANG_UTILITY_H\r
+\r
+#if defined __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+void slang_alloc_free (void *);\r
+void *slang_alloc_malloc (unsigned int);\r
+void *slang_alloc_realloc (void *, unsigned int, unsigned int);\r
+int slang_string_compare (const char *, const char *);\r
+char *slang_string_copy (char *, const char *);\r
+char *slang_string_concat (char *, const char *);\r
+char *slang_string_duplicate (const char *);\r
+unsigned int slang_string_length (const char *);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
index 7c79fe7..1a68057 100644 (file)
@@ -182,7 +182,8 @@ SLANG_CPP_SOURCES = \
        
 SLANG_SOURCES =        \
        shader/slang/slang_compile.c    \
-       shader/slang/slang_preprocess.c
+       shader/slang/slang_preprocess.c \
+       shader/slang/slang_utility.c
 
 ASM_C_SOURCES =        \
        x86/common_x86.c \