From b10d080b1e1f64c2663dde5532b7bcae4fa75325 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 22 Apr 2005 10:15:32 +0000 Subject: Move some utility functions to slang_utility.c. --- src/mesa/shader/slang/slang_compile.c | 43 +-------------------- src/mesa/shader/slang/slang_utility.c | 73 +++++++++++++++++++++++++++++++++++ src/mesa/shader/slang/slang_utility.h | 46 ++++++++++++++++++++++ 3 files changed, 121 insertions(+), 41 deletions(-) create mode 100644 src/mesa/shader/slang/slang_utility.c create mode 100644 src/mesa/shader/slang/slang_utility.h (limited to 'src/mesa/shader/slang') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 5ecef00c1d..d49d104323 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -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" /* @@ -40,46 +41,6 @@ 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 index 0000000000..c07e161c8d --- /dev/null +++ b/src/mesa/shader/slang/slang_utility.c @@ -0,0 +1,73 @@ +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file slang_utility.c + * slang utilities + * \author Michal Krol + */ + +#include "imports.h" +#include "slang_utility.h" + +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); +} + diff --git a/src/mesa/shader/slang/slang_utility.h b/src/mesa/shader/slang/slang_utility.h new file mode 100644 index 0000000000..6eb5369acd --- /dev/null +++ b/src/mesa/shader/slang/slang_utility.h @@ -0,0 +1,46 @@ +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#if !defined SLANG_UTILITY_H +#define SLANG_UTILITY_H + +#if defined __cplusplus +extern "C" { +#endif + +void slang_alloc_free (void *); +void *slang_alloc_malloc (unsigned int); +void *slang_alloc_realloc (void *, unsigned int, unsigned int); +int slang_string_compare (const char *, const char *); +char *slang_string_copy (char *, const char *); +char *slang_string_concat (char *, const char *); +char *slang_string_duplicate (const char *); +unsigned int slang_string_length (const char *); + +#ifdef __cplusplus +} +#endif + +#endif + -- cgit v1.2.3