validate JSON before loading
This commit also introduces slurp() which reads a file in its entirety. Using this function instead of doing IO in the functions in load_layout.c again and again makes the code cleaner (fixing at least two memory leaks) and avoids re-reading the same file 3 times. related to #2755
This commit is contained in:
@ -164,3 +164,11 @@ void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it);
|
||||
* if the number could be parsed.
|
||||
*/
|
||||
bool parse_long(const char *str, long *out, int base);
|
||||
|
||||
/**
|
||||
* Slurp reads path in its entirety into buf, returning the length of the file
|
||||
* or -1 if the file could not be read. buf is set to a buffer of appropriate
|
||||
* size, or NULL if -1 is returned.
|
||||
*
|
||||
*/
|
||||
ssize_t slurp(const char *path, char **buf);
|
||||
|
Reference in New Issue
Block a user