Have wmem conform to checkAPIs.pl

Yes, the rename of structure members is a bit hacky.
Yes, catering to Windows since "GLib's v*printf routines are
surprisingly slow on Windows".
But it does pass checkAPIs.pl

Change-Id: I5b1552472c83aa2e159f17b5b7eb70b37d03eff9
Reviewed-on: https://code.wireshark.org/review/15404
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2016-05-12 13:39:15 -04:00
parent f3e120816c
commit 4d4190f127
8 changed files with 26 additions and 25 deletions

View File

@ -255,15 +255,15 @@ read-only by the allocator implementation.
4.1.2 Consumer Functions
- alloc()
- free()
- realloc()
- walloc()
- wfree()
- wrealloc()
These function pointers should be set to functions with semantics obviously
similar to their standard-library namesakes. Each one takes an extra parameter
that is a copy of the allocator's private_data pointer.
Note that realloc() and free() are not expected to be called directly by user
Note that wrealloc() and wfree() are not expected to be called directly by user
code in most cases - they are primarily optimisations for use by data
structures that wmem might want to implement (it's inefficient, for example, to
implement a dynamically sized array without some form of realloc).
@ -271,8 +271,8 @@ implement a dynamically sized array without some form of realloc).
Also note that allocators do not have to handle NULL pointers or 0-length
requests in any way - those checks are done in an allocator-agnostic way
higher up in wmem. Allocator authors can assume that all incoming pointers
(to realloc and free) are non-NULL, and that all incoming lengths (to malloc
and realloc) are non-0.
(to wrealloc and wfree) are non-NULL, and that all incoming lengths (to walloc
and wrealloc) are non-0.
4.1.3 Producer/Manager Functions

View File

@ -37,9 +37,9 @@ struct _wmem_user_cb_container_t;
* on this structure */
struct _wmem_allocator_t {
/* Consumer functions */
void *(*alloc)(void *private_data, const size_t size);
void (*free)(void *private_data, void *ptr);
void *(*realloc)(void *private_data, void *ptr, const size_t size);
void *(*walloc)(void *private_data, const size_t size);
void (*wfree)(void *private_data, void *ptr);
void *(*wrealloc)(void *private_data, void *ptr, const size_t size);
/* Producer/Manager functions */
void (*free_all)(void *private_data);

View File

@ -1108,9 +1108,9 @@ wmem_block_allocator_init(wmem_allocator_t *allocator)
block_allocator = wmem_new(NULL, wmem_block_allocator_t);
allocator->alloc = &wmem_block_alloc;
allocator->realloc = &wmem_block_realloc;
allocator->free = &wmem_block_free;
allocator->walloc = &wmem_block_alloc;
allocator->wrealloc = &wmem_block_realloc;
allocator->wfree = &wmem_block_free;
allocator->free_all = &wmem_block_free_all;
allocator->gc = &wmem_block_gc;

View File

@ -242,9 +242,9 @@ wmem_block_fast_allocator_init(wmem_allocator_t *allocator)
block_allocator = wmem_new(NULL, wmem_block_fast_allocator_t);
allocator->alloc = &wmem_block_fast_alloc;
allocator->realloc = &wmem_block_fast_realloc;
allocator->free = &wmem_block_fast_free;
allocator->walloc = &wmem_block_fast_alloc;
allocator->wrealloc = &wmem_block_fast_realloc;
allocator->wfree = &wmem_block_fast_free;
allocator->free_all = &wmem_block_fast_free_all;
allocator->gc = &wmem_block_fast_gc;

View File

@ -133,9 +133,9 @@ wmem_simple_allocator_init(wmem_allocator_t *allocator)
simple_allocator = wmem_new(NULL, wmem_simple_allocator_t);
allocator->alloc = &wmem_simple_alloc;
allocator->realloc = &wmem_simple_realloc;
allocator->free = &wmem_simple_free;
allocator->walloc = &wmem_simple_alloc;
allocator->wrealloc = &wmem_simple_realloc;
allocator->wfree = &wmem_simple_free;
allocator->free_all = &wmem_simple_free_all;
allocator->gc = &wmem_simple_gc;

View File

@ -215,9 +215,9 @@ wmem_strict_allocator_init(wmem_allocator_t *allocator)
strict_allocator = wmem_new(NULL, wmem_strict_allocator_t);
allocator->alloc = &wmem_strict_alloc;
allocator->realloc = &wmem_strict_realloc;
allocator->free = &wmem_strict_free;
allocator->walloc = &wmem_strict_alloc;
allocator->wrealloc = &wmem_strict_realloc;
allocator->wfree = &wmem_strict_free;
allocator->free_all = &wmem_strict_free_all;
allocator->gc = &wmem_strict_gc;

View File

@ -53,7 +53,7 @@ wmem_alloc(wmem_allocator_t *allocator, const size_t size)
return NULL;
}
return allocator->alloc(allocator->private_data, size);
return allocator->walloc(allocator->private_data, size);
}
void *
@ -84,7 +84,7 @@ wmem_free(wmem_allocator_t *allocator, void *ptr)
return;
}
allocator->free(allocator->private_data, ptr);
allocator->wfree(allocator->private_data, ptr);
}
void *
@ -105,7 +105,7 @@ wmem_realloc(wmem_allocator_t *allocator, void *ptr, const size_t size)
g_assert(allocator->in_scope);
return allocator->realloc(allocator->private_data, ptr, size);
return allocator->wrealloc(allocator->private_data, ptr, size);
}
static void

View File

@ -31,6 +31,7 @@
#endif
#include <glib.h>
#include <glib/gprintf.h>
#include "wmem_core.h"
#include "wmem_allocator.h"
@ -140,7 +141,7 @@ wmem_strdup_vprintf(wmem_allocator_t *allocator, const gchar *fmt, va_list ap)
dst = (gchar *)wmem_alloc(allocator, needed_len);
vsprintf(dst, fmt, ap2);
vsprintf_s(dst, needed_len, fmt, ap2);
va_end(ap2);