static int keyed_stream_save(void * store_data, void * ctx,
char * tag, uint64_t len, void * buf) {
- return v3_keyed_stream_write_key(store_data, ctx, buf, len);
+ if (v3_keyed_stream_write_key(store_data, ctx, buf, len) != len) {
+ return -1;
+ } else {
+ return 0;
+ }
}
static int keyed_stream_load(void * store_data, void * ctx,
char * tag, uint64_t len, void * buf) {
- return v3_keyed_stream_read_key(store_data, ctx, buf, len);
+ if (v3_keyed_stream_read_key(store_data, ctx, buf, len) != len) {
+ return -1;
+ } else {
+ return 0;
+ }
}
ctx = V3_Malloc(sizeof(struct file_ctx));
+
+ if (!ctx) {
+ PrintError("Cannot allocate\n");
+ return NULL;
+ }
+
memset(ctx, 0, sizeof(struct file_ctx));
ctx->filename = V3_Malloc(strlen(url) + strlen(name) + 5);
+
+ if (!ctx->filename) {
+ PrintError("Cannot allocate\n");
+ V3_Free(ctx);
+ return NULL;
+ }
+
+
memset(ctx->filename, 0, strlen(url) + strlen(name) + 5);
snprintf(ctx->filename, strlen(url) + strlen(name) + 5, "%s/%s", url, name);