Skip to content

Commit 04e88f0

Browse files
Add const specifiers to j0g_* functions
1 parent f150a1c commit 04e88f0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

j0g.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ char *j0g(const char *json, unsigned short *index, int ilen)
1616
}
1717

1818
// return the null-terminated string value matching the given key
19-
char *j0g_str(char *key, char *json, unsigned short *index)
19+
char *j0g_str(const char *key, char *json, const unsigned short *index)
2020
{
2121
int val = j0g_val(key, json, index);
2222
if(!val) return NULL;
2323
return j0g_safe(val, json, index);
2424
}
2525

2626
// null terminate and unescape any string at this value
27-
char *j0g_safe(int val, char *json, unsigned short *index)
27+
char *j0g_safe(int val, char *json, const unsigned short *index)
2828
{
2929
char *str, *cursor;
3030
*(json+(index[val]+index[val+1])) = 0; // null terminate
@@ -47,7 +47,7 @@ char *j0g_safe(int val, char *json, unsigned short *index)
4747
}
4848

4949
// return 1 if the value is the bool value true, number 1, or even the string "true", false otherwise
50-
int j0g_test(char *key, char *json, unsigned short *index)
50+
int j0g_test(const char *key, char *json, const unsigned short *index)
5151
{
5252
char *val = j0g_str(key, json, index);
5353
if(!val) return 0;
@@ -57,7 +57,7 @@ int j0g_test(char *key, char *json, unsigned short *index)
5757
}
5858

5959
// return the index offset of the value matching the given key
60-
int j0g_val(char *key, char *json, unsigned short *index)
60+
int j0g_val(const char *key, char *json, const unsigned short *index)
6161
{
6262
if(!key || !json) return 0;
6363
int i, klen = strlen(key);

j0g.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ char *j0g(const char *json, unsigned short *index, int ilen);
1111
// these functions will modify the json arg in place (to null terminate strings)
1212

1313
// return the null-terminated string value matching the given key
14-
char *j0g_str(char *key, char *json, unsigned short *index);
14+
char *j0g_str(const char *key, char *json, const unsigned short *index);
1515

1616
// return 1 if the value is the bool value true, number 1, or even the string "true", false otherwise
17-
int j0g_test(char *key, char *json, unsigned short *index);
17+
int j0g_test(const char *key, char *json, const unsigned short *index);
1818

1919
// return the index offset of the value matching the given key
20-
int j0g_val(char *key, char *json, unsigned short *index);
20+
int j0g_val(const char *key, char *json, const unsigned short *index);
2121

2222
// unescapes and null terminates any value (useful for arrays)
23-
char *j0g_safe(int val, char *json, unsigned short *index);
23+
char *j0g_safe(int val, char *json, const unsigned short *index);

0 commit comments

Comments
 (0)