Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

consting func args in Parrot_pa_count_used()

  • Loading branch information...
commit 77ee8874bcca4034bcb7e527991f2a5da428d8ad 1 parent ab009a4
Andy Lester petdance authored
Showing with 16 additions and 15 deletions.
  1. +6 −7 include/parrot/pointer_array.h
  2. +10 −8 src/pointer_array.c
13 include/parrot/pointer_array.h
View
@@ -63,9 +63,8 @@ do { \
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
PARROT_EXPORT
-void Parrot_pa_destroy(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
+void Parrot_pa_destroy(PARROT_INTERP, ARGFREE(Parrot_Pointer_Array *self))
+ __attribute__nonnull__(1);
PARROT_EXPORT
PARROT_CAN_RETURN_NULL
@@ -86,6 +85,7 @@ int Parrot_pa_is_owned(PARROT_INTERP,
__attribute__nonnull__(3);
PARROT_EXPORT
+PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Parrot_Pointer_Array * Parrot_pa_new(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -101,19 +101,18 @@ void Parrot_pa_remove(PARROT_INTERP,
PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
size_t Parrot_pa_count_allocated(PARROT_INTERP,
- ARGIN(Parrot_Pointer_Array *self))
+ ARGIN(const Parrot_Pointer_Array *self))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_WARN_UNUSED_RESULT
size_t Parrot_pa_count_used(PARROT_INTERP,
- ARGIN(Parrot_Pointer_Array *self))
+ ARGIN(const Parrot_Pointer_Array *self))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
#define ASSERT_ARGS_Parrot_pa_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(self))
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_pa_insert __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(self) \
18 src/pointer_array.c
View
@@ -44,12 +44,13 @@ Allocate new Pointer_Array.
*/
PARROT_EXPORT
+PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Parrot_Pointer_Array *
Parrot_pa_new(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_pa_new)
- Parrot_Pointer_Array *res = mem_allocate_zeroed_typed(Parrot_Pointer_Array);
+ Parrot_Pointer_Array * const res = mem_allocate_zeroed_typed(Parrot_Pointer_Array);
return res;
}
@@ -65,7 +66,7 @@ Destroy Pointer_Arra and free allocated memory.
PARROT_EXPORT
void
-Parrot_pa_destroy(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self))
+Parrot_pa_destroy(PARROT_INTERP, ARGFREE(Parrot_Pointer_Array *self))
{
ASSERT_ARGS(Parrot_pa_destroy)
size_t i;
@@ -126,8 +127,8 @@ Parrot_pa_insert(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self), ARGIN(void *p
/*
-=item C<size_t Parrot_pa_count_allocated(PARROT_INTERP, Parrot_Pointer_Array
-*self)>
+=item C<size_t Parrot_pa_count_allocated(PARROT_INTERP, const
+Parrot_Pointer_Array *self)>
Get count of allocated objects.
@@ -137,7 +138,7 @@ Get count of allocated objects.
PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
size_t
-Parrot_pa_count_allocated(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self))
+Parrot_pa_count_allocated(PARROT_INTERP, ARGIN(const Parrot_Pointer_Array *self))
{
ASSERT_ARGS(Parrot_pa_count_allocated)
return self->total_chunks * CELL_PER_CHUNK;
@@ -145,7 +146,8 @@ Parrot_pa_count_allocated(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self))
/*
-=item C<size_t Parrot_pa_count_used(PARROT_INTERP, Parrot_Pointer_Array *self)>
+=item C<size_t Parrot_pa_count_used(PARROT_INTERP, const Parrot_Pointer_Array
+*self)>
Get count of allocated objects.
@@ -154,7 +156,7 @@ Get count of allocated objects.
*/
PARROT_WARN_UNUSED_RESULT
size_t
-Parrot_pa_count_used(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self))
+Parrot_pa_count_used(PARROT_INTERP, ARGIN(const Parrot_Pointer_Array *self))
{
ASSERT_ARGS(Parrot_pa_count_used)
size_t count = 0;
@@ -210,7 +212,7 @@ Parrot_pa_is_owned(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self),
/* We can't just deref pointer. It can be garbage */
/* So, ensure that C<ref> is looks like real pointer */
for (i = 0; i < self->total_chunks; i++) {
- Parrot_Pointer_Array_Chunk *chunk = self->chunks[i];
+ const Parrot_Pointer_Array_Chunk * const chunk = self->chunks[i];
if (PTR2UINTVAL(ref) < PTR2UINTVAL(chunk->data))
continue;
if (PTR2UINTVAL(ref) > PTR2UINTVAL(chunk) + CHUNK_SIZE)
Please sign in to comment.
Something went wrong with that request. Please try again.