Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Fan-Control-Daemon
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CeRiAl
Fan-Control-Daemon
Commits
9dfe447e
Commit
9dfe447e
authored
Jul 04, 2012
by
CeRiAl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compilation fixes
parent
cd1a34c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
settings.c
src/settings.c
+5
-4
strmap.c
src/strmap.c
+7
-7
No files found.
src/settings.c
View file @
9dfe447e
...
...
@@ -50,7 +50,6 @@
typedef
struct
Section
Section
;
typedef
struct
ParseState
ParseState
;
typedef
enum
ConvertMode
ConvertMode
;
struct
Settings
{
Section
*
sections
;
...
...
@@ -74,6 +73,8 @@ enum ConvertMode {
CONVERT_MODE_DOUBLE
,
};
typedef
enum
ConvertMode
ConvertMode
;
static
void
trim_str
(
const
char
*
str
,
char
*
out_buf
);
static
int
parse_str
(
Settings
*
settings
,
char
*
str
,
ParseState
*
parse_state
);
static
int
is_blank_char
(
char
c
);
...
...
@@ -95,7 +96,7 @@ Settings * settings_new()
{
Settings
*
settings
;
settings
=
malloc
(
sizeof
(
Settings
));
settings
=
(
Settings
*
)
malloc
(
sizeof
(
Settings
));
if
(
settings
==
NULL
)
{
return
NULL
;
}
...
...
@@ -257,7 +258,7 @@ int settings_set(Settings *settings, const char *section, const char *key, const
s
=
get_section
(
settings
->
sections
,
settings
->
section_count
,
section
);
if
(
s
==
NULL
)
{
/* The section is not created---create it */
s
=
realloc
(
settings
->
sections
,
(
settings
->
section_count
+
1
)
*
sizeof
(
Section
));
s
=
(
Section
*
)
realloc
(
settings
->
sections
,
(
settings
->
section_count
+
1
)
*
sizeof
(
Section
));
if
(
s
==
NULL
)
{
return
0
;
}
...
...
@@ -269,7 +270,7 @@ int settings_set(Settings *settings, const char *section, const char *key, const
free
(
s
);
return
0
;
}
s
->
name
=
malloc
((
strlen
(
section
)
+
1
)
*
sizeof
(
char
));
s
->
name
=
(
char
*
)
malloc
((
strlen
(
section
)
+
1
)
*
sizeof
(
char
));
if
(
s
->
name
==
NULL
)
{
sm_delete
(
s
->
map
);
free
(
s
);
...
...
src/strmap.c
View file @
9dfe447e
...
...
@@ -61,12 +61,12 @@ StrMap * sm_new(unsigned int capacity)
{
StrMap
*
map
;
map
=
malloc
(
sizeof
(
StrMap
));
map
=
(
StrMap
*
)
malloc
(
sizeof
(
StrMap
));
if
(
map
==
NULL
)
{
return
NULL
;
}
map
->
count
=
capacity
;
map
->
buckets
=
malloc
(
map
->
count
*
sizeof
(
Bucket
));
map
->
buckets
=
(
Bucket
*
)
malloc
(
map
->
count
*
sizeof
(
Bucket
));
if
(
map
->
buckets
==
NULL
)
{
free
(
map
);
return
NULL
;
...
...
@@ -187,7 +187,7 @@ int sm_put(StrMap *map, const char *key, const char *value)
/* If the new value is larger than the old value, re-allocate
* space for the new larger value.
*/
tmp_value
=
realloc
(
pair
->
value
,
(
value_len
+
1
)
*
sizeof
(
char
));
tmp_value
=
(
char
*
)
realloc
(
pair
->
value
,
(
value_len
+
1
)
*
sizeof
(
char
));
if
(
tmp_value
==
NULL
)
{
return
0
;
}
...
...
@@ -198,11 +198,11 @@ int sm_put(StrMap *map, const char *key, const char *value)
return
1
;
}
/* Allocate space for a new key and value */
new_key
=
malloc
((
key_len
+
1
)
*
sizeof
(
char
));
new_key
=
(
char
*
)
malloc
((
key_len
+
1
)
*
sizeof
(
char
));
if
(
new_key
==
NULL
)
{
return
0
;
}
new_value
=
malloc
((
value_len
+
1
)
*
sizeof
(
char
));
new_value
=
(
char
*
)
malloc
((
value_len
+
1
)
*
sizeof
(
char
));
if
(
new_value
==
NULL
)
{
free
(
new_key
);
return
0
;
...
...
@@ -212,7 +212,7 @@ int sm_put(StrMap *map, const char *key, const char *value)
/* The bucket is empty, lazily allocate space for a single
* key-value pair.
*/
bucket
->
pairs
=
malloc
(
sizeof
(
Pair
));
bucket
->
pairs
=
(
Pair
*
)
malloc
(
sizeof
(
Pair
));
if
(
bucket
->
pairs
==
NULL
)
{
free
(
new_key
);
free
(
new_value
);
...
...
@@ -224,7 +224,7 @@ int sm_put(StrMap *map, const char *key, const char *value)
/* The bucket wasn't empty but no pair existed that matches the provided
* key, so create a new key-value pair.
*/
tmp_pairs
=
realloc
(
bucket
->
pairs
,
(
bucket
->
count
+
1
)
*
sizeof
(
Pair
));
tmp_pairs
=
(
Pair
*
)
realloc
(
bucket
->
pairs
,
(
bucket
->
count
+
1
)
*
sizeof
(
Pair
));
if
(
tmp_pairs
==
NULL
)
{
free
(
new_key
);
free
(
new_value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment