Cleanup unneeded functions and includes
This commit is contained in:
parent
eaa02d5ab4
commit
7177386801
@ -31,7 +31,6 @@ typedef struct RJP_array{
|
||||
}RJP_array;
|
||||
|
||||
void irjp_add_element(RJP_array* j);
|
||||
void irjp_delete_value(RJP_value* root);
|
||||
void irjp_copy_array(RJP_value* dest, const RJP_value* src);
|
||||
|
||||
RJP_index rjp_dump_array(const RJP_value* arr, char* dest);
|
||||
|
||||
@ -41,17 +41,4 @@ static inline void irjp_ignore_unused(FILE* fp, ...){
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
RJP_value irjp_integer(RJP_int i);
|
||||
RJP_value irjp_boolean(RJP_bool b);
|
||||
RJP_value irjp_dfloat(RJP_float d);
|
||||
RJP_value irjp_string(char* c, RJP_index len);
|
||||
RJP_value irjp_string_copy(const char* c);
|
||||
RJP_value irjp_null(void);
|
||||
RJP_value irjp_object(void);
|
||||
RJP_value irjp_ordered_object(void);
|
||||
RJP_value irjp_array(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -40,4 +40,6 @@ typedef struct RJP_value{
|
||||
enum RJP_data_type type; //flag to determine active member of union
|
||||
}RJP_value;
|
||||
|
||||
void irjp_delete_value(RJP_value* root);
|
||||
|
||||
#endif
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#define RJP_TREE_H
|
||||
|
||||
#include "rjp.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_object_member.h"
|
||||
#include "rjp_value.h"
|
||||
|
||||
#define RJP_TREE_SUCCESS 0
|
||||
#define RJP_TREE_ERR_NULL_ROOT 1
|
||||
@ -45,7 +45,4 @@ RJP_tree_node* irjp_tree_search_value(RJP_tree_node* root, const char* key);
|
||||
RJP_tree_node* irjp_copy_tree(const RJP_tree_node* root);
|
||||
void irjp_free_tree(RJP_tree_node* root);
|
||||
|
||||
void irjp_dbg_print_tree(RJP_tree_node* root);
|
||||
void irjp_dbg_print_tree_bfs(RJP_tree_node* root);
|
||||
|
||||
#endif
|
||||
|
||||
@ -21,10 +21,10 @@
|
||||
|
||||
#include "rjp.h"
|
||||
#include "rjp_internal.h"
|
||||
#include "memory.h"
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_value.h"
|
||||
#include "rjp_array.h"
|
||||
|
||||
#include <string.h> //strlen
|
||||
#include <stdio.h> //sprintf
|
||||
|
||||
33
src/rjp.c
33
src/rjp.c
@ -19,6 +19,7 @@
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_array.h"
|
||||
#include "rjp_value.h"
|
||||
|
||||
#include <stdlib.h> //free, malloc
|
||||
@ -134,35 +135,3 @@ RJP_string* rjp_get_string(RJP_value* value){
|
||||
const RJP_string* rjp_get_cstring(const RJP_value* value){
|
||||
return &(value->string);
|
||||
}
|
||||
|
||||
|
||||
RJP_value irjp_integer(RJP_int i){
|
||||
return (RJP_value){.integer = i, .type = rjp_json_integer};
|
||||
}
|
||||
RJP_value irjp_boolean(RJP_bool b){
|
||||
return (RJP_value){.boolean = b, .type = rjp_json_boolean};
|
||||
}
|
||||
RJP_value irjp_dfloat(RJP_float d){
|
||||
return (RJP_value){.dfloat = d, .type = rjp_json_dfloat};
|
||||
}
|
||||
RJP_value irjp_string(char* c, RJP_index len){
|
||||
return (RJP_value){.string = {.value = c, .length = len}, .type = rjp_json_string};
|
||||
}
|
||||
RJP_value irjp_string_copy(const char* c){
|
||||
RJP_index esclen = rjp_escape_strlen(c);
|
||||
char* tmp = rjp_alloc(esclen+1);
|
||||
rjp_escape_strcpy(tmp, c);
|
||||
return (RJP_value){.string = {.value = tmp, .length = esclen}, .type = rjp_json_string};
|
||||
}
|
||||
RJP_value irjp_null(void){
|
||||
return (RJP_value){.integer = 0, .type = rjp_json_null};
|
||||
}
|
||||
RJP_value irjp_object(void){
|
||||
return (RJP_value){.object = {0}, .type = rjp_json_object};
|
||||
}
|
||||
RJP_value irjp_ordered_object(void){
|
||||
return (RJP_value){.object = {0}, .type = rjp_json_ordered_object};
|
||||
}
|
||||
RJP_value irjp_array(void){
|
||||
return (RJP_value){.array = {0}, .type = rjp_json_array};
|
||||
}
|
||||
|
||||
@ -16,8 +16,10 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "rjp_array.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_array.h"
|
||||
#include "rjp_value.h"
|
||||
#include "rjp_array_element.h"
|
||||
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "rjp_internal.h"
|
||||
#include "tree.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_object_member.h"
|
||||
#include "rjp_value.h"
|
||||
|
||||
#include <string.h> //strlen, strncpy
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_value.h"
|
||||
#include "rjp_string.h"
|
||||
#include "memory.h"
|
||||
#include "rjp_lex.h"
|
||||
#include <stdlib.h> //strtod, strtol
|
||||
#include <string.h> //memcpy
|
||||
|
||||
@ -19,13 +19,11 @@
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_value.h"
|
||||
|
||||
#include <stdio.h> //fprintf
|
||||
#include <stdlib.h> //malloc, free
|
||||
#include <stdint.h> //uintN_t
|
||||
#include <string.h> //strcpy
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_unordered_object.h"
|
||||
#include "rjp_value.h"
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_object_member.h"
|
||||
#include "tree.h"
|
||||
#include <string.h> //strlen
|
||||
|
||||
|
||||
70
src/tree.c
70
src/tree.c
@ -19,12 +19,11 @@
|
||||
#include "tree.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rjp_string.h"
|
||||
#include "rjp_internal.h"
|
||||
#include "rjp_object.h"
|
||||
#include "rjp_value.h"
|
||||
|
||||
#define BLACK 0
|
||||
#define RED 1
|
||||
@ -269,73 +268,6 @@ RJP_tree_node* irjp_tree_search_value(RJP_tree_node* root, const char* key){
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
//Debug printouts
|
||||
void irjp_dbg_print_tree(RJP_tree_node* root){
|
||||
if(!root){
|
||||
return;
|
||||
}
|
||||
RJP_tree_node* current = root, *pre;
|
||||
while(current){
|
||||
if(!current->left){
|
||||
printf("%s\n", current->data.name.value);
|
||||
current = current->right;
|
||||
}else{
|
||||
pre = current->left;
|
||||
while(pre->right && pre->right != current){
|
||||
pre = pre->right;
|
||||
}
|
||||
if(!pre->right){
|
||||
pre->right = current;
|
||||
current = current->left;
|
||||
}else{
|
||||
pre->right = NULL;
|
||||
printf("%s\n", current->data.name.value);
|
||||
current = current->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#define pop() front = (front+1)%queuelen
|
||||
#define push(val, dp) do{queue[rear].n = (val);queue[rear].depth = (dp);rear = (rear+1)%queuelen;}while(0)
|
||||
struct tmpthing{
|
||||
RJP_tree_node* n;
|
||||
int depth;
|
||||
};
|
||||
|
||||
void irjp_dbg_print_tree_bfs(RJP_tree_node* root){
|
||||
int queuelen = 64;
|
||||
struct tmpthing queue[64];
|
||||
int front = 0, rear = 0;
|
||||
int lastdepth = 0;
|
||||
|
||||
push(root, lastdepth);
|
||||
while(front != rear){
|
||||
if(lastdepth != queue[front].depth){
|
||||
lastdepth = queue[front].depth;
|
||||
printf("\n");
|
||||
}
|
||||
if(!queue[front].n){
|
||||
printf("*");
|
||||
}else{
|
||||
printf("%s ", queue[front].n->data.name.value);
|
||||
if(queue[front].n->left){
|
||||
push(queue[front].n->left, queue[front].depth+1);
|
||||
}else{
|
||||
push(NULL,queue[front].depth+1);
|
||||
}
|
||||
if(queue[front].n->right){
|
||||
push(queue[front].n->right, queue[front].depth+1);
|
||||
}else{
|
||||
push(NULL,queue[front].depth+1);
|
||||
}
|
||||
}
|
||||
pop();
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#undef pop
|
||||
#undef push
|
||||
|
||||
RJP_tree_node* irjp_tree_remove_value(RJP_tree_node* restrict root, RJP_tree_node* restrict member, RJP_tree_node** removed_node){
|
||||
if(!root)
|
||||
return root;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user