Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset bb7e6fc5 in mainline


Ignore:
Timestamp:
2011-12-09T21:41:35Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
c24b272f
Parents:
3342f33
Message:

Do not create an initial span on ra_arena_create().

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/lib/ra.h

    r3342f33 rbb7e6fc5  
    7777} ra_segment_t;
    7878
    79 extern ra_arena_t *ra_arena_create(uintptr_t, size_t);
     79extern ra_arena_t *ra_arena_create(void);
    8080extern bool ra_span_add(ra_arena_t *, uintptr_t, size_t);
    8181extern uintptr_t ra_alloc(ra_arena_t *, size_t, size_t);
  • kernel/generic/src/lib/ra.c

    r3342f33 rbb7e6fc5  
    174174}
    175175
    176 /** Create arena with initial span. */
    177 ra_arena_t *ra_arena_create(uintptr_t base, size_t size)
     176/** Create an empty arena. */
     177ra_arena_t *ra_arena_create(void)
    178178{
    179179        ra_arena_t *arena;
     180
     181        arena = (ra_arena_t *) malloc(sizeof(ra_arena_t), FRAME_ATOMIC);
     182        if (!arena)
     183                return NULL;
     184
     185        spinlock_initialize(&arena->lock, "arena_lock");
     186        list_initialize(&arena->spans);
     187
     188        return arena;
     189}
     190
     191/** Add a span to arena. */
     192bool ra_span_add(ra_arena_t *arena, uintptr_t base, size_t size)
     193{
    180194        ra_span_t *span;
    181195
     
    185199         * slightly change the API of the resource allocator.
    186200         */
    187         if (base == 0)
    188                 return NULL;
    189 
    190         arena = (ra_arena_t *) malloc(sizeof(ra_arena_t), FRAME_ATOMIC);
    191         if (!arena)
    192                 return NULL;
    193 
    194         span = ra_span_create(base, size);
    195         if (!span) {
    196                 free(arena);
    197                 return NULL;
    198         }
    199 
    200         spinlock_initialize(&arena->lock, "arena_lock");
    201         list_initialize(&arena->spans);
    202         list_append(&span->span_link, &arena->spans);
    203 
    204         return arena;
    205 }
    206 
    207 /** Add additional span to arena. */
    208 bool ra_span_add(ra_arena_t *arena, uintptr_t base, size_t size)
    209 {
    210         ra_span_t *span;
    211 
    212201        if (base == 0)
    213202                return false;
Note: See TracChangeset for help on using the changeset viewer.