Skip to content
Snippets Groups Projects
Commit 5516e125 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: sieve-storage - Split off sieve_storage_alloc_from_class()

parent 2f259962
No related branches found
No related tags found
No related merge requests found
......@@ -289,10 +289,13 @@ sieve_storage_data_parse(struct sieve_storage *storage, const char *data,
* Storage instance
*/
int sieve_storage_alloc(struct sieve_instance *svinst, struct event *event,
const struct sieve_storage *storage_class,
const char *data, enum sieve_storage_flags flags,
bool main, struct sieve_storage **storage_r)
static int
sieve_storage_alloc_from_class(struct sieve_instance *svinst,
struct event *event,
const struct sieve_storage *storage_class,
const char *data,
enum sieve_storage_flags flags,
struct sieve_storage **storage_r)
{
struct sieve_storage *storage;
......@@ -304,24 +307,49 @@ int sieve_storage_alloc(struct sieve_instance *svinst, struct event *event,
storage->storage_class = storage_class;
storage->refcount = 1;
storage->svinst = svinst;
storage->flags = flags;
storage->data = p_strdup_empty(storage->pool, data);
storage->main_storage = main;
storage->flags = flags;
if (event != NULL) {
storage->event = event;
event_ref(storage->event);
} else {
event = sieve_storage_create_event(svinst, svinst->event);
storage->event = sieve_storage_create_driver_event(
event, storage_class->driver_name);
event_unref(&event);
}
storage->event = event;
event_ref(event);
*storage_r = storage;
return 0;
}
int sieve_storage_alloc(struct sieve_instance *svinst, struct event *event,
const struct sieve_storage *storage_class,
const char *data, enum sieve_storage_flags flags,
bool main, struct sieve_storage **storage_r)
{
struct sieve_storage *storage;
int ret;
*storage_r = NULL;
if (event != NULL)
event_ref(event);
else {
struct event *storage_event;
storage_event = sieve_storage_create_event(
svinst, svinst->event);
event = sieve_storage_create_driver_event(
storage_event, storage_class->driver_name);
event_unref(&storage_event);
}
ret = sieve_storage_alloc_from_class(svinst, event, storage_class,
data, flags, &storage);
if (ret == 0)
storage->main_storage = main;
event_unref(&event);
*storage_r = storage;
return ret;
}
static int
sieve_storage_init_real(struct sieve_instance *svinst, struct event *event,
const struct sieve_storage *storage_class,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.