Permalink
Browse files

adding tracing for the slot APIs

  • Loading branch information...
tonycoz committed Sep 17, 2012
1 parent 88adfaa commit 61495d699ac1972eba1c2c76d937eaf0eb1eac8c
Showing with 28 additions and 13 deletions.
  1. +1 −1 FT2/freetyp2.c
  2. +17 −2 context.c
  3. +1 −2 fontft1.c
  4. +1 −1 imager.h
  5. +1 −1 imext.h
  6. +1 −1 imexttypes.h
  7. +4 −3 lib/Imager/API.pod
  8. +1 −1 lib/Imager/APIRef.pod
  9. +1 −1 t/t82inline.t
View
@@ -65,7 +65,7 @@ static i_img_dim i_max(i_img_dim a, i_img_dim b);
void
i_ft2_start(void) {
if (slot == -1)
- slot = im_context_slot_new(ft2_final);
+ slot = im_context_slot_new(ft2_final, "FT2");
}
/*
View
@@ -189,15 +189,15 @@ im_context_clone(im_context_t ctx, const char *where) {
}
/*
-=item im_context_slot_new(destructor)
+=item im_context_slot_new(destructor, where)
Allocate a new context-local-storage slot.
=cut
*/
im_slot_t
-im_context_slot_new(im_slot_destroy_t destructor) {
+im_context_slot_new(im_slot_destroy_t destructor, const char *where) {
im_slot_t new_slot;
im_slot_destroy_t *new_destructors;
if (!slot_mutex)
@@ -213,6 +213,11 @@ im_context_slot_new(im_slot_destroy_t destructor) {
slot_destructors[new_slot] = destructor;
+#ifdef IMAGER_TRACE_CONTEXT
+ fprintf(stderr, "im_context: slot %d allocated for %s\n",
+ (int)new_slot, where);
+#endif
+
i_mutex_unlock(slot_mutex);
return new_slot;
@@ -257,6 +262,11 @@ im_context_slot_set(im_context_t ctx, im_slot_t slot, void *value) {
ctx->slots[slot] = value;
+#ifdef IMAGER_TRACE_CONTEXT
+ fprintf(stderr, "im_context: ctx %p slot %d set to %p\n",
+ ctx, (int)slot, value);
+#endif
+
return 1;
}
@@ -280,5 +290,10 @@ im_context_slot_get(im_context_t ctx, im_slot_t slot) {
if (slot >= ctx->slot_alloc)
return NULL;
+#ifdef IMAGER_TRACE_CONTEXT
+ fprintf(stderr, "im_context: ctx %p slot %d retrieved as %p\n",
+ ctx, (int)slot, ctx->slots[slot]);
+#endif
+
return ctx->slots[slot];
}
View
@@ -150,9 +150,8 @@ static int LTT_hinted = 1; /* FIXME: this too */
void
i_tt_start(void) {
- im_context_t ctx = im_get_context();
if (slot == -1)
- slot = im_context_slot_new(i_tt_uninit);
+ slot = im_context_slot_new(i_tt_uninit, "TT");
}
View
@@ -386,7 +386,7 @@ extern im_context_t im_context_new(void);
extern void im_context_refinc(im_context_t ctx, const char *where);
extern void im_context_refdec(im_context_t ctx, const char *where);
extern im_context_t im_context_clone(im_context_t ctx, const char *where);
-extern im_slot_t im_context_slot_new(im_slot_destroy_t);
+extern im_slot_t im_context_slot_new(im_slot_destroy_t, const char *);
extern void *im_context_slot_get(im_context_t ctx, im_slot_t slot);
extern int im_context_slot_set(im_context_t ctx, im_slot_t slot, void *);
View
@@ -232,7 +232,7 @@ extern im_ext_funcs *imager_function_ext_table;
#define i_mutex_lock(m) ((im_extt->f_i_mutex_lock)(m))
#define i_mutex_unlock(m) ((im_extt->f_i_mutex_unlock)(m))
-#define im_context_slot_new(destructor) ((im_extt->f_im_context_slot_new)(destructor))
+#define im_context_slot_new(destructor, where) ((im_extt->f_im_context_slot_new)((destructor), (where)))
#define im_context_slot_get(ctx, slot) ((im_extt->f_im_context_slot_get)((ctx), (slot)))
#define im_context_slot_set(ctx, slot, value) ((im_extt->f_im_context_slot_set)((ctx), (slot), (value)))
View
@@ -232,7 +232,7 @@ typedef struct {
void (*f_i_mutex_destroy)(i_mutex_t m);
void (*f_i_mutex_lock)(i_mutex_t m);
void (*f_i_mutex_unlock)(i_mutex_t m);
- im_slot_t (*f_im_context_slot_new)(im_slot_destroy_t);
+ im_slot_t (*f_im_context_slot_new)(im_slot_destroy_t, const char *);
int (*f_im_context_slot_set)(im_context_t, im_slot_t, void *);
void *(*f_im_context_slot_get)(im_context_t, im_slot_t);
} im_ext_funcs;
View
@@ -447,10 +447,11 @@ Imager provides simple APIs for storing per-context information.
To allocate a slot:
- im_slot_t slot = im_context_slot_new(callback)
+ im_slot_t slot = im_context_slot_new(callback, where)
-where callback is a (possibly NULL) function pointer called when the
-context object is destroyed.
+where I<callback> is a (possibly NULL) function pointer called when
+the context object is destroyed, and I<where> is a brief description
+of what the slot is used for.
By default, the stored value for a slot is NULL, whether for a new
context or for a cloned context.
View
@@ -2302,7 +2302,7 @@ object.
=for comment
From: File context.c
-=item im_context_slot_new(destructor)
+=item im_context_slot_new(destructor, where)
Allocate a new context-local-storage slot.
View
@@ -422,7 +422,7 @@ test_mutex() {
int
test_slots() {
- im_slot_t slot = im_context_slot_new(NULL);
+ im_slot_t slot = im_context_slot_new(NULL, "t82inline");
if (im_context_slot_get(aIMCTX, slot)) {
fprintf(stderr, "slots should default to NULL\n");

0 comments on commit 61495d6

Please sign in to comment.