~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to lib/ofpbuf.c

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
 
2
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
3
3
 *
4
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
5
 * you may not use this file except in compliance with the License.
29
29
    b->allocated = allocated;
30
30
    b->source = source;
31
31
    b->size = 0;
32
 
    b->l2 = b->l3 = b->l4 = b->l7 = NULL;
 
32
    b->l2 = b->l2_5 = b->l3 = b->l4 = b->l7 = NULL;
33
33
    list_poison(&b->list_node);
34
34
    b->private_p = NULL;
35
35
}
52
52
 *
53
53
 * 'base' should be appropriately aligned.  Using an array of uint32_t or
54
54
 * uint64_t for the buffer is a reasonable way to ensure appropriate alignment
55
 
 * for 32- or 64-bit data.  OFPBUF_STACK_BUFFER is a convenient way to do so.
 
55
 * for 32- or 64-bit data.
56
56
 *
57
57
 * An ofpbuf operation that requires reallocating data will assert-fail if this
58
58
 * function was used to initialize it.  Thus, one need not call ofpbuf_uninit()
67
67
/* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of
68
68
 * memory starting at 'base'.  'base' should point to a buffer on the stack.
69
69
 * (Nothing actually relies on 'base' being allocated on the stack.  It could
70
 
 * be static or malloc()'d memory.  But stack space is the most common usen
 
70
 * be static or malloc()'d memory.  But stack space is the most common use
71
71
 * case.)
72
72
 *
73
73
 * 'base' should be appropriately aligned.  Using an array of uint32_t or
74
74
 * uint64_t for the buffer is a reasonable way to ensure appropriate alignment
75
 
 * for 32- or 64-bit data.  OFPBUF_STACK_BUFFER is a convenient way to do so.
 
75
 * for 32- or 64-bit data.
76
76
 *
77
77
 * An ofpbuf operation that requires reallocating data will copy the provided
78
78
 * buffer into a malloc()'d buffer.  Thus, it is wise to call ofpbuf_uninit()
176
176
    if (buffer->l2) {
177
177
        new_buffer->l2 = (char *) buffer->l2 + data_delta;
178
178
    }
 
179
    if (buffer->l2_5) {
 
180
        new_buffer->l2_5 = (char *) buffer->l2_5 + data_delta;
 
181
    }
179
182
    if (buffer->l3) {
180
183
        new_buffer->l3 = (char *) buffer->l3 + data_delta;
181
184
    }
295
298
        if (b->l2) {
296
299
            b->l2 = (char *) b->l2 + data_delta;
297
300
        }
 
301
        if (b->l2_5) {
 
302
            b->l2_5 = (char *) b->l2_5 + data_delta;
 
303
        }
298
304
        if (b->l3) {
299
305
            b->l3 = (char *) b->l3 + data_delta;
300
306
        }