~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/kcreddb/buf.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:28:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030102853-x7v876vw4af46v0m
Tags: 1.4.4-3ubuntu1
* Merge with Debian; only Ubuntu change:
  - src/include/k5-thread.h: Define__USE_GNU when #include'ing pthread.h to
    fix FTBFS (from 1.4.3-9ubuntu1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2004 Massachusetts Institute of Technology
 
2
 * Copyright (c) 2005 Massachusetts Institute of Technology
3
3
 *
4
4
 * Permission is hereby granted, free of charge, to any person
5
5
 * obtaining a copy of this software and associated documentation
29
29
 
30
30
void kcdb_buf_new(kcdb_buf * buf, khm_size n_fields)
31
31
{
32
 
    buf->buffer = malloc(KCDB_BUF_CBBUF_INITIAL);
 
32
    buf->buffer = PMALLOC(KCDB_BUF_CBBUF_INITIAL);
33
33
    buf->cb_buffer = KCDB_BUF_CBBUF_INITIAL;
34
34
    buf->cb_used = 0;
35
35
 
40
40
 
41
41
    buf->n_fields = n_fields;
42
42
    buf->nc_fields = UBOUNDSS(n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);
43
 
    buf->fields = malloc(sizeof(buf->fields[0]) * buf->n_fields);
 
43
    buf->fields = PMALLOC(sizeof(buf->fields[0]) * buf->n_fields);
44
44
    ZeroMemory(buf->fields, sizeof(buf->fields[0]) * buf->n_fields);
45
45
}
46
46
 
49
49
    buf->cb_buffer = 0;
50
50
    buf->cb_used = 0;
51
51
    if(buf->buffer)
52
 
        free(buf->buffer);
 
52
        PFREE(buf->buffer);
53
53
    buf->buffer = NULL;
54
54
 
55
55
    buf->n_fields = 0;
56
56
    buf->nc_fields = 0;
57
57
    if(buf->fields)
58
 
        free(buf->fields);
 
58
        PFREE(buf->fields);
59
59
    buf->fields = NULL;
60
60
}
61
61
 
73
73
 
74
74
    assert(new_size > buf->cb_buffer && new_size > 0);
75
75
 
76
 
    new_buf = malloc(new_size);
 
76
    new_buf = PMALLOC(new_size);
77
77
    assert(new_buf != NULL);
78
78
 
79
79
    memcpy(new_buf, buf->buffer, buf->cb_used);
80
 
    free(buf->buffer);
 
80
    PFREE(buf->buffer);
81
81
    buf->buffer = new_buf;
82
82
}
83
83
 
106
106
 
107
107
        ns = UBOUNDSS((slot + 1), KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);
108
108
 
109
 
        nf = malloc(sizeof(buf->fields[0]) * ns);
 
109
        nf = PMALLOC(sizeof(buf->fields[0]) * ns);
110
110
        memcpy(nf, buf->fields, sizeof(buf->fields[0]) * buf->n_fields);
111
111
 
112
112
        if(ns > buf->n_fields)
113
113
            memset(&(nf[buf->n_fields]), 0, sizeof(buf->fields[0]) * (ns - buf->n_fields));
114
114
 
115
 
        free(buf->fields);
 
115
        PFREE(buf->fields);
116
116
        buf->fields = nf;
117
117
        buf->nc_fields = ns;
118
118
    }
134
134
        }
135
135
 
136
136
        if(buf->cb_used > f->offset + cbold) {
137
 
            int i;
 
137
            khm_size i;
138
138
 
139
139
            memmove(
140
140
                ((BYTE *) buf->buffer) + (f->offset + cbnew),
191
191
 
192
192
    dest->cb_buffer = cb_buf;
193
193
    dest->cb_used = src->cb_used;
194
 
    dest->buffer = malloc(cb_buf);
 
194
    dest->buffer = PMALLOC(cb_buf);
195
195
    memcpy(dest->buffer, src->buffer, src->cb_used);
196
196
 
197
197
    nc_fields = UBOUNDSS(src->n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);
198
198
    dest->nc_fields = nc_fields;
199
199
    dest->n_fields = src->n_fields;
200
 
    dest->fields = malloc(nc_fields * sizeof(dest->fields[0]));
 
200
    dest->fields = PMALLOC(nc_fields * sizeof(dest->fields[0]));
201
201
    memcpy(dest->fields, src->fields, src->n_fields * sizeof(dest->fields[0]));
202
202
    if(dest->n_fields < dest->nc_fields)
203
203
        memset(&(dest->fields[dest->n_fields]), 0, (src->nc_fields - src->n_fields) * sizeof(dest->fields[0]));
293
293
    else if(kcdb_is_active_identity(record))
294
294
        return kcdb_identity_get_attr(record, attr_id, attr_type, buffer, pcb_buf);
295
295
    else
296
 
        return KHM_ERROR_INVALID_PARM;
 
296
        return KHM_ERROR_INVALID_PARAM;
297
297
}
298
298
 
299
299
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib(
308
308
    else if(kcdb_is_active_identity(record))
309
309
        return kcdb_identity_get_attrib(record, attr_name, attr_type, buffer, pcb_buf);
310
310
    else
311
 
        return KHM_ERROR_INVALID_PARM;
 
311
        return KHM_ERROR_INVALID_PARAM;
312
312
}
313
313
 
314
314
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attr_string(
323
323
    else if(kcdb_is_active_identity(record))
324
324
        return kcdb_identity_get_attr_string(record, attr_id, buffer, pcbbuf, flags);
325
325
    else
326
 
        return KHM_ERROR_INVALID_PARM;
 
326
        return KHM_ERROR_INVALID_PARAM;
327
327
}
328
328
 
329
329
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib_string(
338
338
    else if(kcdb_is_active_identity(record))
339
339
        return kcdb_identity_get_attrib_string(record, attr_name, buffer, pcbbuf, flags);
340
340
    else
341
 
        return KHM_ERROR_INVALID_PARM;
 
341
        return KHM_ERROR_INVALID_PARAM;
342
342
}
343
343
 
344
344
KHMEXP khm_int32 KHMAPI kcdb_buf_set_attr(
352
352
    else if(kcdb_is_active_identity(record))
353
353
        return kcdb_identity_set_attr(record, attr_id, buffer, cbbuf);
354
354
    else
355
 
        return KHM_ERROR_INVALID_PARM;
 
355
        return KHM_ERROR_INVALID_PARAM;
356
356
}
357
357
 
358
358
KHMEXP khm_int32 KHMAPI kcdb_buf_set_attrib(
366
366
    else if(kcdb_is_active_identity(record))
367
367
        return kcdb_identity_set_attrib(record, attr_name, buffer, cbbuf);
368
368
    else
369
 
        return KHM_ERROR_INVALID_PARM;
 
369
        return KHM_ERROR_INVALID_PARAM;
370
370
}
371
371
 
372
372
KHMEXP khm_int32 KHMAPI kcdb_buf_hold(khm_handle  record)
376
376
    else if(kcdb_is_active_identity(record))
377
377
        return kcdb_identity_hold(record);
378
378
    else
379
 
        return KHM_ERROR_INVALID_PARM;
 
379
        return KHM_ERROR_INVALID_PARAM;
380
380
}
381
381
 
382
382
KHMEXP khm_int32 KHMAPI kcdb_buf_release(khm_handle record)
386
386
    else if(kcdb_is_active_identity(record))
387
387
        return kcdb_identity_release(record);
388
388
    else
389
 
        return KHM_ERROR_INVALID_PARM;
 
389
        return KHM_ERROR_INVALID_PARAM;
390
390
}
391
391