~ubuntu-branches/ubuntu/karmic/libvirt/karmic-proposed

« back to all changes in this revision

Viewing changes to src/qparams.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2009-02-11 01:01:42 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090211010142-8zrm7z1u6ryfhkiq
Tags: 0.6.0-1ubuntu1
* Merge with Debian experimental. Remaining changes:
  - debian/control:
    + Don't build-depend on QEmu.
    + Add "XS-Debian-" prefix to Debian's Vcs headers.
    + Bump bridge-utils, dnsmasq-base, netcat-openbsd, and iptables
      to Depends of libvirt-bin.
    + s/interract/interact/g
    + Add versioned Conflicts/Replaces to libvirt0 for libvirt0-dbg,
      since we used to ship them as such.
  - Rename libvirt group to libvirtd.
  - 0005-delayed_iff_up_bridge.patch: Don't try to bring up the bridge
    before at least one interface has been added to it.
  - dont_clobber_existing_bridges.patch: Assign the name of the virtual
    bridge dynamically to avoid interfering with existing bridges.
  - better_default_uri_virsh.patch: Default to qemu:///system if the
    user has write access to the libvirt socket, otherwise
    qemu:///session.
  - We call libxen-dev libxen3-dev, so change all references.
  - Included (but did not enable) opennebula patch (since it's not in
    main yet).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2007 Red Hat, Inc.
 
1
/* Copyright (C) 2007, 2009 Red Hat, Inc.
2
2
 *
3
3
 * This library is free software; you can redistribute it and/or
4
4
 * modify it under the terms of the GNU Lesser General Public
33
33
#include "memory.h"
34
34
#include "qparams.h"
35
35
 
36
 
#define qparam_report_oom(void)                                              \
37
 
        virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_NO_MEMORY,       \
38
 
                               __FILE__, __FUNCTION__, __LINE__, NULL)
 
36
#define VIR_FROM_THIS VIR_FROM_NONE
39
37
 
40
38
struct qparam_set *
41
39
new_qparam_set (int init_alloc, ...)
47
45
    if (init_alloc <= 0) init_alloc = 1;
48
46
 
49
47
    if (VIR_ALLOC(ps) < 0) {
50
 
        qparam_report_oom();
 
48
        virReportOOMError(NULL);
51
49
        return NULL;
52
50
    }
53
51
    ps->n = 0;
54
52
    ps->alloc = init_alloc;
55
53
    if (VIR_ALLOC_N(ps->p, ps->alloc) < 0) {
56
54
        VIR_FREE (ps);
57
 
        qparam_report_oom();
 
55
        virReportOOMError(NULL);
58
56
        return NULL;
59
57
    }
60
58
 
98
96
{
99
97
    if (ps->n >= ps->alloc) {
100
98
        if (VIR_REALLOC_N(ps->p, ps->alloc * 2) < 0) {
101
 
            qparam_report_oom();
 
99
            virReportOOMError(NULL);
102
100
            return -1;
103
101
        }
104
102
        ps->alloc *= 2;
115
113
 
116
114
    pname = strdup (name);
117
115
    if (!pname) {
118
 
        qparam_report_oom();
 
116
        virReportOOMError(NULL);
119
117
        return -1;
120
118
    }
121
119
 
122
120
    pvalue = strdup (value);
123
121
    if (!pvalue) {
124
122
        VIR_FREE (pname);
125
 
        qparam_report_oom();
 
123
        virReportOOMError(NULL);
126
124
        return -1;
127
125
    }
128
126
 
156
154
    }
157
155
 
158
156
    if (virBufferError(&buf)) {
159
 
        qparam_report_oom();
 
157
        virReportOOMError(NULL);
160
158
        return NULL;
161
159
    }
162
160
 
184
182
 
185
183
    ps = new_qparam_set (0, NULL);
186
184
    if (!ps) {
187
 
        qparam_report_oom();
 
185
        virReportOOMError(NULL);
188
186
        return NULL;
189
187
    }
190
188
 
257
255
    return ps;
258
256
 
259
257
 out_of_memory:
260
 
    qparam_report_oom();
 
258
    virReportOOMError(NULL);
261
259
    free_qparam_set (ps);
262
260
    return NULL;
263
261
}