]> git.sesse.net Git - vlc/blob - modules/visualization/galaktos/tree_types.c
Remove _GNU_SOURCE and string.h too
[vlc] / modules / visualization / galaktos / tree_types.c
1 /*****************************************************************************
2  * tree_types.c:
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet <asmax@videolan.org>
8  *          code from projectM http://xmms-projectm.sourceforge.net
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25
26
27 #include <stdio.h>
28 #include "common.h"
29
30 /* Compares integer value numbers in 32 bit range */
31 int compare_int(int * num1, int * num2) {
32
33         if ((*num1) < (*num2))
34                 return -1;
35         if ((*num1) > (*num2))
36                 return 1;
37         
38         return 0;
39 }
40
41 /* Compares strings in lexographical order */
42 int compare_string(char * str1, char * str2) {
43
44   //  printf("comparing \"%s\" to \"%s\"\n", str1, str2);
45   //return strcmp(str1, str2);
46   return strncmp(str1, str2, MAX_TOKEN_SIZE-1);
47         
48 }       
49
50 /* Compares a string in version order. That is, file1 < file2 < file10 */
51 int compare_string_version(char * str1, char * str2) {
52
53   return strverscmp(str1, str2);
54
55 }
56
57
58 void free_int(void * num) {
59         free(num);
60 }
61
62
63 void free_string(char * string) {
64         
65         free(string);   
66 }       
67  
68 void * copy_int(int * num) {
69         
70         int * new_num;
71         
72         if ((new_num = (int*)malloc(sizeof(int))) == NULL)
73                 return NULL;
74
75         *new_num = *num;
76         
77         return (void*)new_num;
78 }       
79
80
81 void * copy_string(char * string) {
82         
83         char * new_string;
84         
85         if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL)
86                 return NULL;
87         
88         strncpy(new_string, string, MAX_TOKEN_SIZE-1);
89         
90         return (void*)new_string;
91 }