Merge remote branch 'origin/gallium-0.2' into gallium-0.2
[mesa.git] / src / mesa / shader / grammar / grammar_crt.c
1 #include "grammar_crt.h"
2
3 #define GRAMMAR_PORT_BUILD 1
4 #include "grammar.c"
5 #undef GRAMMAR_PORT_BUILD
6
7
8 void grammar_alloc_free (void *ptr)
9 {
10 free (ptr);
11 }
12
13 void *grammar_alloc_malloc (size_t size)
14 {
15 return malloc (size);
16 }
17
18 void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
19 {
20 return realloc (ptr, size);
21 }
22
23 void *grammar_memory_copy (void *dst, const void * src, size_t size)
24 {
25 return memcpy (dst, src, size);
26 }
27
28 int grammar_string_compare (const byte *str1, const byte *str2)
29 {
30 return strcmp ((const char *) str1, (const char *) str2);
31 }
32
33 int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
34 {
35 return strncmp ((const char *) str1, (const char *) str2, n);
36 }
37
38 byte *grammar_string_copy (byte *dst, const byte *src)
39 {
40 return (byte *) strcpy ((char *) dst, (const char *) src);
41 }
42
43 byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
44 {
45 return (byte *) strncpy ((char *) dst, (const char *) src, n);
46 }
47
48 unsigned int grammar_string_length (const byte *str)
49 {
50 return strlen ((const char *) str);
51 }
52
53 byte *grammar_string_duplicate (const byte *src)
54 {
55 const unsigned int size = grammar_string_length (src);
56 byte *str = grammar_alloc_malloc (size + 1);
57 if (str != NULL)
58 {
59 grammar_memory_copy (str, src, size);
60 str[size] = '\0';
61 }
62 return str;
63 }
64