Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 #include <string.h>
00034
00035 #include "ld_res.h"
00036 #include "ld_cmd.h"
00037
00038 #include "../../mem/mem.h"
00039 #include "../../dprint.h"
00040 #include "../../lib/srdb2/db_gen.h"
00041
00042
00043 static void ld_res_free(db_res_t* res, struct ld_res* payload)
00044 {
00045 db_drv_free(&payload->gen);
00046 if (payload->msg) ldap_msgfree(payload->msg);
00047 payload->msg = NULL;
00048 pkg_free(payload);
00049 }
00050
00051
00052 int ld_res(db_res_t* res)
00053 {
00054 struct ld_res* lres;
00055
00056 lres = (struct ld_res*)pkg_malloc(sizeof(struct ld_res));
00057 if (lres == NULL) {
00058 ERR("ldap: No memory left\n");
00059 return -1;
00060 }
00061 memset(lres, '\0', sizeof(struct ld_res));
00062 if (db_drv_init(&lres->gen, ld_res_free) < 0) goto error;
00063 DB_SET_PAYLOAD(res, lres);
00064 return 0;
00065
00066 error:
00067 if (lres) {
00068 db_drv_free(&lres->gen);
00069 pkg_free(lres);
00070 }
00071 return -1;
00072 }
00073