[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Struct type attributes interface
From: |
Konstantinos Chasialis |
Subject: |
[PATCH] Struct type attributes interface |
Date: |
Wed, 1 Jul 2020 01:50:51 +0300 |
User-agent: |
SquirrelMail/1.4.23 [email.uoa.gr] |
Hello, I have made the changes we discussed on previous thread about
removing pk_alloc and pk_assert from pk_* interface and moved json-schema
to etc/.
Author: kostasch <sdi1600195@di.uoa.gr>
Date: Wed Jul 1 01:46:51 2020
Changes to pk-val interface for struct types
ChangeLog | 11 ++++
etc/pk-mi-json-schema.json | 284
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
libpoke/libpoke.h | 24 ++++----
libpoke/pk-val.c | 44 ++++++-------
poke/pk-mi-json.c | 46 +++++++-------
poke/pk-mi-json.h | 3 +-
6 files changed, 352 insertions(+), 60 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b735ed0b..f3870098 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-07-01 Kostas Chasialis <sdi1600195@di.uoa.gr>
+ * etc/pk-mi-json-schema.json : Moved from poke/
+ * libpoke/libpoke.h (pk_allocate_struct_attrs) : Prototype.
+ (pk_alloc) : Removed.
+ (pk_assert) : Likewise.
+ * libpoke/pk-val.c (pk_allocate_struct_attrs) : Define.
+ (pk_alloc) : Removed.
+ (pk_assert) : Likewise.
+ * poke/pk-mi-json.c : Adaptive changes based on the changes above.
+ * poke/pk-mi-json.h : Likewise.
+
2020-06-06 Kostas Chasialis <sdi1600195@di.uoa.gr>
* poke/pk-mi-json-schema.json : JSON Schema.
diff --git a/etc/pk-mi-json-schema.json b/etc/pk-mi-json-schema.json
new file mode 100644
index 00000000..ea894500
--- /dev/null
+++ b/etc/pk-mi-json-schema.json
@@ -0,0 +1,284 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "",
+ "title": "Poke values",
+ "description": "JSON Representation for Poke values",
+ "definitions": {
+ "UnsignedInteger": {
+ "type": "object",
+ "properties": {
+ "type" : {
+ "type" : "string",
+ "const" : "UnsignedInteger"
+ },
+ "value": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 18446744073709551615
+ },
+ "size": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 64
+ }
+ },
+ "maxProperties" : 3,
+ "required": [
+ "size",
+ "value",
+ "type"
+ ],
+ "title": "UnsignedInteger"
+ },
+ "Integer": {
+ "type": "object",
+ "properties": {
+ "type" : {
+ "type" : "string",
+ "const" : "Integer"
+ },
+ "value": {
+ "type": "integer",
+ "minimum": -9223372036854775808,
+ "maximum": 9223372036854775807
+ },
+ "size": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 64
+ }
+ },
+ "maxProperties" : 3,
+ "required": [
+ "size",
+ "value",
+ "type"
+ ],
+ "title": "Integer"
+ },
+ "String": {
+ "type": "object",
+ "properties": {
+ "type" : {
+ "type" : "string",
+ "const" : "String"
+ },
+ "value": {
+ "type": "string"
+ }
+ },
+ "maxProperties" : 2,
+ "required": [
+ "value",
+ "type"
+ ],
+ "title": "String"
+ },
+ "Offset": {
+ "type": "object",
+ "properties": {
+ "type" : {
+ "type" : "string",
+ "const" : "Offset"
+ },
+ "magnitude": {
+ "type": "object",
+ "oneOf": [
+ {
+ "$ref": "#/definitions/UnsignedInteger"
+ },
+ {
+ "$ref": "#/definitions/Integer"
+ }
+ ]
+ },
+ "unit": {
+ "type": "object",
+ "allOf" : [
+ {"$ref": "#/definitions/UnsignedInteger"}
+ ],
+ "properties" : {
+ "size" : {
+ "const" : 64
+ }
+ },
+ "required" : ["size"]
+ }
+ },
+ "maxProperties" : 3,
+ "required": [
+ "magnitude",
+ "base",
+ "type"
+ ],
+ "title": "Offset"
+ },
+ "StructField" : {
+ "type" : "object",
+ "properties" : {
+ "offset" : {
+ "type" : "object",
+ "$ref" : "#/definitions/Offset"
+ },
+ "name" : {
+ "type" : "object",
+ "$ref" : "#/definitions/String"
+ },
+ "value" : {
+ "type" : "object",
+ "anyOf" : [
+ {"$ref": "#/definitions/String"},
+ {"$ref": "#/definitions/Struct"},
+ {"$ref": "#/definitions/Array"},
+ {"$ref": "#/definitions/UnsignedInteger"},
+ {"$ref": "#/definitions/Integer"},
+ {"$ref": "#/definitions/Offset"}
+ ]
+ }
+ },
+ "maxProperties": 3,
+ "required" : [
+ "offset",
+ "name",
+ "value"
+ ]
+ },
+ "Struct": {
+ "type":"object",
+ "properties":{
+ "type" : {
+ "type" : "string",
+ "const" : "Struct"
+ },
+ "name" : {
+ "type" : "object",
+ "$ref" : "#/definitions/String"
+ },
+ "fields": {
+ "type" : "array",
+ "items" : {
+ "type" : "object",
+ "$ref" : "#/definitions/StructField"
+ }
+ },
+ "mapping" : {
+ "type" : "object",
+ "oneOf" : [
+ {"$ref" : "#/definitions/Mapping"},
+ {"$ref" : "#/definitions/Null"}
+ ]
+ }
+ },
+ "maxProperties" : 3,
+ "required": [
+ "fields",
+ "type",
+ "mapping",
+ "name"
+ ],
+ "title": "Struct"
+ },
+ "Mapping": {
+ "type": "object",
+ "properties": {
+ "IOS": {
+ "type": "integer",
+ "minimum" : -2147483648,
+ "maximum" : 2147483647
+ },
+ "offset": {
+ "type": "object",
+ "$ref": "#/definitions/Offset"
+ }
+ },
+ "maxProperties": 2,
+ "required": [
+ "IOS",
+ "offset"
+ ],
+ "title": "Mapping"
+ },
+ "Array": {
+ "type" : "object",
+ "properties" : {
+ "type" : {
+ "type" : "string",
+ "const" : "Array"
+ },
+ "elements" : {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties" : {
+ "value" : {
+ "type" : "object",
+ "oneOf" : [
+ {"$ref": "#/definitions/Integer"},
+ {"$ref":
"#/definitions/UnsignedInteger"},
+ {"$ref": "#/definitions/String"},
+ {"$ref": "#/definitions/Struct"},
+ {"$ref": "#/definitions/Array"},
+ {"$ref": "#/definitions/Offset"},
+ {"$ref": "#/definitions/Null"}
+ ]
+ },
+ "offset" : {
+ "type" : "object",
+ "$ref" : "#/definitions/Offset"
+ }
+ },
+ "maxProperties" : 2,
+ "required" : [
+ "value",
+ "offset"
+ ]
+ }
+ },
+ "mapping" : {
+ "type" : "object",
+ "oneOf" : [
+ {"$ref" : "#/definitions/Mapping"},
+ {"$ref" : "#/definitions/Null"}
+ ]
+ }
+ },
+ "maxProperties" : 3,
+ "required" : [
+ "elements",
+ "type",
+ "mapping"
+ ]
+ },
+ "Null": {
+ "type": "object",
+ "properties" : {
+ "type" : {
+ "type" : "string",
+ "const" : "Null"
+ },
+ "value" : {
+ "type" : "null"
+ }
+ },
+ "maxProperties" : 2,
+ "required" : ["type", "value"],
+ "title": "Null"
+ }
+ },
+ "type": "object",
+ "properties": {
+ "PokeValue" : {
+ "type" : "object",
+ "anyOf" : [
+ {"$ref": "#/definitions/Integer"},
+ {"$ref": "#/definitions/UnsignedInteger"},
+ {"$ref": "#/definitions/String"},
+ {"$ref": "#/definitions/Struct"},
+ {"$ref": "#/definitions/Array"},
+ {"$ref": "#/definitions/Offset"},
+ {"$ref": "#/definitions/Null"}
+ ]
+ }
+ },
+ "additionalProperties": false
+}
\ No newline at end of file
diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h
index 8a76d1ac..3b3533ed 100644
--- a/libpoke/libpoke.h
+++ b/libpoke/libpoke.h
@@ -404,10 +404,6 @@ void pk_set_pretty_print (pk_compiler pkc, int
pretty_print_p);
#define PK_NULL 0x7ULL
-void *pk_alloc (size_t size);
-
-void pk_assert (int expression);
-
/* Signed integers. */
/* Build and return a poke integer.
@@ -689,13 +685,17 @@ pk_val pk_make_struct_type (pk_val nfields, pk_val
name, pk_val *fnames, pk_val
pk_val pk_struct_type (pk_val sct);
+/* Allocate space for struct fields names and field types. */
+
+void pk_allocate_struct_attrs (pk_val nfields, pk_val **fnames, pk_val
**ftypes);
+
/* Get the name of a struct type. */
-pk_val pk_struct_type_name (pk_val sct_type);
+pk_val pk_struct_type_name (pk_val type);
/* Get the number of fields of a struct type. */
-pk_val pk_struct_type_nfields (pk_val sct_type);
+pk_val pk_struct_type_nfields (pk_val type);
/* Get the name of a field in a struct type.
@@ -703,9 +703,9 @@ pk_val pk_struct_type_nfields (pk_val sct_type);
IDX is the index of the field in a struct type. */
-pk_val pk_struct_type_fname (pk_val sct_type, uint64_t idx);
+pk_val pk_struct_type_fname (pk_val type, uint64_t idx);
-/* Set the name of a field a struct type.
+/* Set the name of a field of a struct type.
TYPE is a struct type.
@@ -713,7 +713,7 @@ pk_val pk_struct_type_fname (pk_val sct_type, uint64_t
idx);
NAME is a string containing the name of the field in a struct type. */
-void pk_struct_type_set_fname (pk_val sct_type, uint64_t idx, pk_val name);
+void pk_struct_type_set_fname (pk_val type, uint64_t idx, pk_val
field_name);
/* Get type of a field in the struct.
@@ -721,9 +721,9 @@ void pk_struct_type_set_fname (pk_val sct_type,
uint64_t idx, pk_val name);
IDX is the index of the struct field. */
-pk_val pk_struct_type_ftype (pk_val sct_type, uint64_t idx);
+pk_val pk_struct_type_ftype (pk_val type, uint64_t idx);
-/* Set the type of a field a struct type.
+/* Set the type of a field of a struct type.
TYPE is a struct type.
@@ -731,7 +731,7 @@ pk_val pk_struct_type_ftype (pk_val sct_type, uint64_t
idx);
TYPE is the type of the field in a struct type. */
-void pk_struct_type_set_ftype (pk_val sct_type, uint64_t idx, pk_val type);
+void pk_struct_type_set_ftype (pk_val type, uint64_t idx, pk_val
field_type);
/* Array types. */
diff --git a/libpoke/pk-val.c b/libpoke/pk-val.c
index 12fc7593..ecf95d39 100644
--- a/libpoke/pk-val.c
+++ b/libpoke/pk-val.c
@@ -23,18 +23,6 @@
#include "pvm-val.h" /* XXX */
#include "libpoke.h"
-void*
-pk_alloc (size_t size)
-{
- return pvm_alloc (size);
-}
-
-void
-pk_assert (int expression)
-{
- return pvm_assert (expression);
-}
-
pk_val
pk_make_int (int64_t value, int size)
{
@@ -321,40 +309,46 @@ pk_struct_type (pk_val sct)
return PVM_VAL_SCT_TYPE (sct);
}
+void
+pk_allocate_struct_attrs (pk_val nfields, pk_val **fnames, pk_val **ftypes)
+{
+ pvm_allocate_struct_attrs (nfields, fnames, ftypes);
+}
+
pk_val
-pk_struct_type_name (pk_val sct_type)
+pk_struct_type_name (pk_val type)
{
- return PVM_VAL_TYP_S_NAME (sct_type);
+ return PVM_VAL_TYP_S_NAME (type);
}
pk_val
-pk_struct_type_nfields (pk_val sct_type)
+pk_struct_type_nfields (pk_val type)
{
- return PVM_VAL_TYP_S_NFIELDS (sct_type);
+ return PVM_VAL_TYP_S_NFIELDS (type);
}
pk_val
-pk_struct_type_fname (pk_val sct_type, uint64_t idx)
+pk_struct_type_fname (pk_val type, uint64_t idx)
{
- return PVM_VAL_TYP_S_FNAME (sct_type, idx);
+ return PVM_VAL_TYP_S_FNAME (type, idx);
}
void
-pk_struct_type_set_fname (pk_val sct_type, uint64_t idx, pk_val name)
+pk_struct_type_set_fname (pk_val type, uint64_t idx, pk_val field_name)
{
- PVM_VAL_TYP_S_FNAME (sct_type, idx) = name;
+ PVM_VAL_TYP_S_FNAME (type, idx) = field_name;
}
pk_val
-pk_struct_type_ftype (pk_val sct_type, uint64_t idx)
+pk_struct_type_ftype (pk_val type, uint64_t idx)
{
- return PVM_VAL_TYP_S_FTYPE (sct_type, idx);
+ return PVM_VAL_TYP_S_FTYPE (type, idx);
}
void
-pk_struct_type_set_ftype (pk_val sct_type, uint64_t idx, pk_val type)
+pk_struct_type_set_ftype (pk_val type, uint64_t idx, pk_val field_type)
{
- PVM_VAL_TYP_S_FTYPE (sct_type, idx) = type;
+ PVM_VAL_TYP_S_FTYPE (type, idx) = field_type;
}
pk_val
@@ -391,4 +385,4 @@ void
pk_array_set_elem_boffset (pk_val array, uint64_t idx, pk_val boffset)
{
PVM_VAL_ARR_ELEM_OFFSET (array, idx) = boffset;
-}
+}
\ No newline at end of file
diff --git a/poke/pk-mi-json.c b/poke/pk-mi-json.c
index 517d5bea..38221f36 100644
--- a/poke/pk-mi-json.c
+++ b/poke/pk-mi-json.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
#include <config.h>
#include <string.h>
#include <json.h>
@@ -119,7 +120,7 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
/* Request has no args. */
break;
default:
- pk_assert (0);
+ assert (0);
}
json_object_object_add (json, "data", req);
@@ -165,7 +166,7 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
/* Response has no result. */
break;
default:
- pk_assert (0);
+ assert (0);
}
json_object_object_add (json, "data", resp);
@@ -211,14 +212,14 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
break;
}
default:
- pk_assert (0);
+ assert (0);
}
json_object_object_add (json, "data", event);
break;
}
default:
- pk_assert (0);
+ assert (0);
}
return json;
@@ -472,7 +473,7 @@ static json_object* _pk_mi_val_to_json (pk_val val,
char **errmsg)
break;
case PK_CLOSURE:
case PK_ANY:
- pk_assert (0);
+ assert (0);
}
if (!pk_val_object) {
return NULL;
@@ -489,7 +490,7 @@ _pk_mi_make_json_int (pk_val integer, char **errmsg)
const char *type;
int size;
- pk_assert (pk_type_code (pk_typeof (integer)) == PK_INT);
+ assert (pk_type_code (pk_typeof (integer)) == PK_INT);
PK_MI_CHECK (errmsg, (int_object = json_object_new_object ()) != NULL,
"json_object_new_object() failed");
@@ -504,7 +505,7 @@ _pk_mi_make_json_int (pk_val integer, char **errmsg)
type = "Integer";
}
- pk_assert (size <= 64);
+ assert (size <= 64);
PK_MI_CHECK (errmsg, (size_object = json_object_new_int (size)) !=
NULL, "json_object_new_object() failed");
PK_MI_CHECK (errmsg, (type_object = json_object_new_string (type)) !=
NULL, "json_object_new_object() failed");
@@ -525,7 +526,7 @@ _pk_mi_make_json_string (pk_val str, char **errmsg)
{
struct json_object *string_object, *string_type_object,
*string_value_object;
- pk_assert (pk_type_code (pk_typeof (str)) == PK_STRING);
+ assert (pk_type_code (pk_typeof (str)) == PK_STRING);
PK_MI_CHECK (errmsg, (string_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
@@ -549,7 +550,7 @@ _pk_mi_make_json_offset (pk_val offset, char **errmsg)
struct json_object *magnitude_object;
struct json_object *unit_object, *unit_type_object, *unit_size_object,
*unit_value_object;
- pk_assert (pk_type_code (pk_typeof (offset)) == PK_OFFSET);
+ assert (pk_type_code (pk_typeof (offset)) == PK_OFFSET);
PK_MI_CHECK (errmsg, (offset_type_object = json_object_new_string
("Offset")) != NULL, "json_object_new_object() failed");
@@ -604,7 +605,7 @@ _pk_mi_make_json_struct (pk_val sct, char **errmsg)
struct json_object *pk_struct_object, *pk_struct_type_object,
*pk_struct_fields_object, *pk_struct_name_object,
*pk_struct_mapping_object;
struct json_object *pk_struct_field_object,
*pk_struct_field_value_object, *pk_struct_field_offset_object,
*pk_struct_field_name_object;
- pk_assert (pk_type_code (pk_typeof (sct)) == PK_STRUCT);
+ assert (pk_type_code (pk_typeof (sct)) == PK_STRUCT);
PK_MI_CHECK (errmsg, (pk_struct_type_object = json_object_new_string
("Struct")) != NULL, "json_object_new_object() failed");
PK_MI_CHECK (errmsg, (pk_struct_fields_object = json_object_new_array
()) != NULL, "json_object_new_object() failed");
@@ -650,7 +651,7 @@ _pk_mi_make_json_array (pk_val array, char **errmsg)
struct json_object *pk_array_object, *pk_array_type_object,
*pk_array_elements_object, *pk_array_mapping_object;
struct json_object *pk_array_element_object,
*pk_array_element_value_object, *pk_array_element_offset_object;
- pk_assert (pk_type_code (pk_typeof (array)) == PK_ARRAY);
+ assert (pk_type_code (pk_typeof (array)) == PK_ARRAY);
PK_MI_CHECK (errmsg, (pk_array_object = json_object_new_object ()) !=
NULL, "json_object_new_object() failed");
@@ -816,10 +817,10 @@ _pk_mi_make_pk_offset (pk_val *pk_offset, struct
json_object *offset_obj, char *
PK_MI_CHECK (errmsg, json_object_object_get_ex (offset_obj, "unit",
&unit_object) != 0, "json type %s does not contain key \"unit\"",
_pk_mi_get_json_poke_value_type (offset_obj));
- pk_assert (json_object_get_type (unit_object) == json_type_object);
+ assert (json_object_get_type (unit_object) == json_type_object);
PK_MI_CHECK (errmsg, _pk_mi_make_pk_uint (&unit, unit_object, errmsg)
!= -1, "unable to conver offset unit to pk_uint");
- pk_assert (pk_uint_size (unit) == 64);
+ assert (pk_uint_size (unit) == 64);
*pk_offset = pk_make_offset (magnitude, unit);
PK_MI_CHECK(errmsg, *pk_offset != PK_NULL, "pk_make_offset failed");
@@ -848,7 +849,7 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
PK_MI_CHECK (errmsg, json_object_object_get_ex (sct_obj, "fields",
&search_object) != 0, "json type %s does does not contain key
\"fields\"", _pk_mi_get_json_poke_value_type (sct_obj));
fields_object = search_object;
- pk_assert (json_object_get_type (fields_object) == json_type_array);
+ assert (json_object_get_type (fields_object) == json_type_array);
fields_len = json_object_array_length (fields_object);
@@ -856,8 +857,7 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
PK_MI_CHECK (errmsg, json_object_object_get_ex (sct_obj, "name",
&search_object) != 0, "json type %s does does not contain key
\"name\"", _pk_mi_get_json_poke_value_type (sct_obj));
nfields = pk_make_uint (fields_len, 64);
name = _pk_mi_json_to_val (search_object, errmsg);
- fnames = pk_alloc (sizeof (pk_val) * fields_len);
- ftypes = pk_alloc (sizeof (pk_val) * fields_len);
+ pk_allocate_struct_attrs (nfields, &fnames, &ftypes);
sct_type = pk_make_struct_type (nfields, name, fnames, ftypes);
sct = pk_make_struct (nfields, sct_type);
@@ -871,8 +871,8 @@ _pk_mi_make_pk_struct (pk_val *pk_struct, struct
json_object *sct_obj, char **er
PK_MI_CHECK (errmsg, json_object_object_get_ex
(json_object_array_get_idx (fields_object, i), "offset",
&search_object) != 0, "json type %s does not contain key
\"offset\"", _pk_mi_get_json_poke_value_type
(json_object_array_get_idx (fields_object, i)));
sct_field_offset = _pk_mi_json_to_val (search_object, errmsg);
- pk_assert (pk_type_code (pk_typeof (sct_field_name)) == PK_STRING);
- pk_assert (pk_type_code (pk_typeof (sct_field_offset)) == PK_OFFSET);
+ assert (pk_type_code (pk_typeof (sct_field_name)) == PK_STRING);
+ assert (pk_type_code (pk_typeof (sct_field_offset)) == PK_OFFSET);
pk_struct_type_set_fname (sct_type, i, sct_field_name);
pk_struct_type_set_ftype (sct_type, i, pk_typeof(sct_field_value));
@@ -901,7 +901,7 @@ _pk_mi_json_array_element_pair (struct json_object
*elements_object, size_t idx,
{
struct json_object *element_object, *search_object;
/*value-offset pair*/
- pk_val *pair = pk_alloc (sizeof (pk_val) * 2);
+ pk_val *pair = (pk_val *) malloc (sizeof (pk_val) * 2);
element_object = json_object_array_get_idx (elements_object, idx);
@@ -928,7 +928,7 @@ _pk_mi_make_pk_array (pk_val *pk_array, struct
json_object *array_obj, char **er
PK_MI_CHECK (errmsg, json_object_object_get_ex (array_obj, "elements",
&search_object) != 0, "json type %s does not contain key \"elements\"",
_pk_mi_get_json_poke_value_type (array_obj));
elements_object = search_object;
- pk_assert (json_object_get_type (elements_object) == json_type_array);
+ assert (json_object_get_type (elements_object) == json_type_array);
elements_len = json_object_array_length (elements_object);
@@ -948,8 +948,8 @@ _pk_mi_make_pk_array (pk_val *pk_array, struct
json_object *array_obj, char **er
for (size_t i = 1 ; i < elements_len ; i++) {
element_pair = _pk_mi_json_array_element_pair (elements_object, i,
errmsg);
- pk_assert (pk_type_code (pk_typeof (element_pair[0])) == array_etype);
- pk_assert (pk_type_code (pk_typeof (element_pair[1])) == PK_OFFSET);
+ assert (pk_type_code (pk_typeof (element_pair[0])) == array_etype);
+ assert (pk_type_code (pk_typeof (element_pair[1])) == PK_OFFSET);
pk_array_set_elem_val (array, i, element_pair[0]);
pk_array_set_elem_boffset (array, i, element_pair[1]);
@@ -958,6 +958,8 @@ _pk_mi_make_pk_array (pk_val *pk_array, struct
json_object *array_obj, char **er
PK_MI_CHECK (errmsg, json_object_object_get_ex (array_obj, "mapping",
&search_object) != 0, "json type %s does not contain key
\"mapping\"", _pk_mi_get_json_poke_value_type (array_obj));
mapping = pk_mi_make_pk_mapping (search_object);
+
+ free(element_pair);
}
else {
array = PK_NULL;
diff --git a/poke/pk-mi-json.h b/poke/pk-mi-json.h
index ad289bcd..d59ad717 100644
--- a/poke/pk-mi-json.h
+++ b/poke/pk-mi-json.h
@@ -19,6 +19,7 @@
#ifndef PK_MI_JSON
#define PK_MI_JSON
+#include <stdlib.h>
#include <config.h>
#include "pk-mi-msg.h"
@@ -31,7 +32,7 @@
#define PK_MI_CHECK(errmsg, A, M, ...) \
if(!(A)) { \
if (errmsg == NULL) goto error; \
- *errmsg = (char *) pk_alloc (1024); \
+ *errmsg = (char *) malloc (1024); \
PK_MI_SET_ERRMSG(errmsg, M, ##__VA_ARGS__); goto error;}
#define PK_MI_DEBUG(M, ...) \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Struct type attributes interface,
Konstantinos Chasialis <=