set_default.c
1 /*
2  shm-arena shared memory arena
3  Copyright (C) 2006-2008 Lance Arsenault (LGPL v3)
4 
5 
6  This file is part of shm-arena.
7 
8  shm-arena is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12 
13  shm-arena is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this program. If not, see
20  <http://www.gnu.org/licenses/>.
21 */
22 
27 #include "config.h"
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <errno.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <stdint.h>
34 #include <sys/stat.h>
35 #include <fcntl.h>
36 #include <stdlib.h>
37 
38 #include <pthread.h>
39 #include "spew.h"
40 #include "assert.h"
41 #include "debug_lock.h"
42 #include "shm_arena.h"
43 #include "arena.h"
44 #include "arena_lock.h"
45 
46 
57 {
58  int ret = 0;
59 
60  pthread_mutex_lock(&_shm_create_arena_mutex);
61 
62  if(_shm_default_arena) ret = 1;
63 
64  _shm_default_arena = arena;
65 
66  pthread_mutex_unlock(&_shm_create_arena_mutex);
67 
68  SPEW(_INFO,
69  "%s(arena=%p) %s default arena",
70  __func__, arena, (ret)?"replaced":"set");
71  return ret;
72 }
int shm_arena_set_default(const shm_arena_t arena)
set the local default arena object
Definition: set_default.c:56

Shared Memory Arena version RC-0.0.25