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