1 #include "grammar_crt.h"
3 #define GRAMMAR_PORT_BUILD 1
5 #undef GRAMMAR_PORT_BUILD
8 void grammar_alloc_free (void *ptr
)
13 void *grammar_alloc_malloc (unsigned int size
)
18 void *grammar_alloc_realloc (void *ptr
, unsigned int old_size
, unsigned int size
)
20 return realloc (ptr
, size
);
23 void *grammar_memory_copy (void *dst
, const void * src
, unsigned int size
)
25 return memcpy (dst
, src
, size
);
28 int grammar_string_compare (const byte
*str1
, const byte
*str2
)
30 return strcmp ((const char *) str1
, (const char *) str2
);
33 int grammar_string_compare_n (const byte
*str1
, const byte
*str2
, unsigned int n
)
35 return strncmp ((const char *) str1
, (const char *) str2
, n
);
38 byte
*grammar_string_copy (byte
*dst
, const byte
*src
)
40 return (byte
*) strcpy ((char *) dst
, (const char *) src
);
43 byte
*grammar_string_copy_n (byte
*dst
, const byte
*src
, unsigned int n
)
45 return (byte
*) strncpy ((char *) dst
, (const char *) src
, n
);
48 unsigned int grammar_string_length (const byte
*str
)
50 return strlen ((const char *) str
);
53 byte
*grammar_string_duplicate (const byte
*src
)
55 const unsigned int size
= grammar_string_length (src
);
56 byte
*str
= grammar_alloc_malloc (size
+ 1);
59 grammar_memory_copy (str
, src
, size
);