]> git.sesse.net Git - vlc/blob - modules/visualization/galaktos/tree_types.c
Make Zorglub less unhappy
[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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include "common.h"
31
32 /* Compares integer value numbers in 32 bit range */
33 int compare_int(int * num1, int * num2) {
34
35         if ((*num1) < (*num2))
36                 return -1;
37         if ((*num1) > (*num2))
38                 return 1;
39         
40         return 0;
41 }
42
43 /* Compares strings in lexographical order */
44 int compare_string(char * str1, char * str2) {
45
46   //  printf("comparing \"%s\" to \"%s\"\n", str1, str2);
47   //return strcmp(str1, str2);
48   return strncmp(str1, str2, MAX_TOKEN_SIZE-1);
49         
50 }       
51
52 /* Compares a string in version order. That is, file1 < file2 < file10 */
53 int compare_string_version(char * str1, char * str2) {
54
55   return strverscmp(str1, str2);
56
57 }
58
59
60 void free_int(void * num) {
61         free(num);
62 }
63
64
65 void free_string(char * string) {
66         
67         free(string);   
68 }       
69  
70 void * copy_int(int * num) {
71         
72         int * new_num;
73         
74         if ((new_num = (int*)malloc(sizeof(int))) == NULL)
75                 return NULL;
76
77         *new_num = *num;
78         
79         return (void*)new_num;
80 }       
81
82
83 void * copy_string(char * string) {
84         
85         char * new_string;
86         
87         if ((new_string = (char*)malloc(MAX_TOKEN_SIZE)) == NULL)
88                 return NULL;
89         
90         strncpy(new_string, string, MAX_TOKEN_SIZE-1);
91         
92         return (void*)new_string;
93 }