mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
don't inline pool_zalloc(); lift duplicated pool_str(n)dup to pool.c
This commit is contained in:
parent
6e4b011dac
commit
a43a1312d2
@ -195,25 +195,3 @@ void pool_abandon_object(struct pool *p)
|
||||
p->begun = 0;
|
||||
p->object = NULL;
|
||||
}
|
||||
|
||||
char *pool_strdup(struct pool *p, const char *str)
|
||||
{
|
||||
char *ret = pool_alloc(p, strlen(str) + 1);
|
||||
|
||||
if (ret)
|
||||
strcpy(ret, str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *pool_strndup(struct pool *p, const char *str, size_t n)
|
||||
{
|
||||
char *ret = pool_alloc(p, n + 1);
|
||||
|
||||
if (ret) {
|
||||
strncpy(ret, str, n);
|
||||
ret[n] = '\0';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -195,28 +195,6 @@ void pool_abandon_object(struct pool *p)
|
||||
p->object_alignment = DEFAULT_ALIGNMENT;
|
||||
}
|
||||
|
||||
char *pool_strdup(struct pool *p, const char *str)
|
||||
{
|
||||
char *ret = pool_alloc(p, strlen(str) + 1);
|
||||
|
||||
if (ret)
|
||||
strcpy(ret, str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *pool_strndup(struct pool *p, const char *str, size_t n)
|
||||
{
|
||||
char *ret = pool_alloc(p, n + 1);
|
||||
|
||||
if (ret) {
|
||||
strncpy(ret, str, n);
|
||||
ret[n] = '\0';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _align_chunk(struct chunk *c, unsigned alignment)
|
||||
{
|
||||
c->begin += alignment - ((unsigned long) c->begin & (alignment - 1));
|
||||
|
@ -9,3 +9,35 @@
|
||||
#else
|
||||
#include "pool-fast.c"
|
||||
#endif
|
||||
|
||||
char *pool_strdup(struct pool *p, const char *str)
|
||||
{
|
||||
char *ret = pool_alloc(p, strlen(str) + 1);
|
||||
|
||||
if (ret)
|
||||
strcpy(ret, str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *pool_strndup(struct pool *p, const char *str, size_t n)
|
||||
{
|
||||
char *ret = pool_alloc(p, n + 1);
|
||||
|
||||
if (ret) {
|
||||
strncpy(ret, str, n);
|
||||
ret[n] = '\0';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *pool_zalloc(struct pool *p, size_t s)
|
||||
{
|
||||
void *ptr = pool_alloc(p, s);
|
||||
|
||||
if (ptr)
|
||||
memset(ptr, 0, s);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@ -107,15 +107,6 @@ void pool_abandon_object(struct pool *p);
|
||||
/* utilities */
|
||||
char *pool_strdup(struct pool *p, const char *str);
|
||||
char *pool_strndup(struct pool *p, const char *str, size_t n);
|
||||
|
||||
static inline void *pool_zalloc(struct pool *p, size_t s)
|
||||
{
|
||||
void *ptr = pool_alloc(p, s);
|
||||
|
||||
if (ptr)
|
||||
memset(ptr, 0, s);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
void *pool_zalloc(struct pool *p, size_t s);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user