case EZ_BLOB_INT8 | EZ_BLOB_CSTRING:
strings = 1;
break;
+ case EZ_BLOB_TRANSIENTP:
+ break;
default:
fprintf(stderr, "Unsupported type: %d\n", d->bd_type);
abort();
case EZ_BLOB_INT64:
case EZ_BLOB_FLOAT32:
case EZ_BLOB_FLOAT64:
+ case EZ_BLOB_TRANSIENTP:
break;
case EZ_BLOB_INT8 | EZ_BLOB_CSTRING:
if (doinline) {
printf("\tb = string_encode(b, *(const char **)(p + %d));\n", d->bd_offset);
}
break;
+ case EZ_BLOB_TRANSIENTP:
+ break;
default:
fprintf(stderr, "Unsupported type: %d\n", d->bd_type);
abort();
printf("\tb = string_decode(b, (char **)(p + %d));\n", d->bd_offset);
}
break;
+ case EZ_BLOB_TRANSIENTP:
+ break;
default:
fprintf(stderr, "Unsupported type: %d\n", d->bd_type);
abort();
void *v = p + d->bd_offset;
int st = d->bd_type & EZ_BLOB_STORAGE;
int dt = d->bd_type & EZ_BLOB_TYPE;
-
+
switch (st) {
case EZ_BLOB_SINGLE:
if (dt == EZ_BLOB_STRUCT)
}
break;
case EZ_BLOB_CSTRING:
+ case EZ_BLOB_TRANSIENTP:
free(((char **)v)[0]);
break;
case EZ_BLOB_VECTOR:
break;
}
}
+ memset(p, 0, desc->bd_offset);
}
void ez_blob_free(const ez_blob_desc *d, void *p) {
EZ_BLOB_SINGLE = 0x00, // the value at bd_offset
EZ_BLOB_SINGLEP = 0x10, // pointer to value at bd_offset
EZ_BLOB_CSTRING = 0x20, // 0-terminated string pointer
+ EZ_BLOB_TRANSIENTP = 0x30, // transient pointer which needs to be free()'d on free
EZ_BLOB_VECTOR = 0x40, // ez_blob at bd_offset
EZ_BLOB_VECTORP = 0x50, // pointer to ez_blob at bd_offset
#define EZ_BLOB_STRING(s, id, f) { EZ_BLOB_INT8 | EZ_BLOB_CSTRING, id, offsetof(s, f), #f }
#define EZ_BLOB_STRINGN(s, id, f) { EZ_BLOB_INT8 | EZ_BLOB_CSTRING | EZ_BLOB_ISNULLABLE, id, offsetof(s, f), #f }
+#define EZ_BLOB_TRANSIENTP(s, id, f) { EZ_BLOB_TRANSIENTP, id, offsetof(s, f), #f }
+
#define EZ_BLOB_STRUCT(s, id, f, other) { EZ_BLOB_STRUCT | EZ_BLOB_SINGLE, id, offsetof(s, f), #f, .bd_table = other }
#define EZ_BLOB_STRUCTP(s, id, f, other) { EZ_BLOB_STRUCT | EZ_BLOB_SINGLEP, id, offsetof(s, f), #f, .bd_table = other }
#define EZ_BLOB_STRUCTPN(s, id, f, other) { EZ_BLOB_STRUCT | EZ_BLOB_SINGLEP | EZ_BLOB_ISNULLABLE, id, offsetof(s, f), #f, .bd_table = other }