ObjFW  Check-in [32ccf22a44]

Overview
Comment:More documentation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 32ccf22a444fecdd6109004ef6293678aff47c827e70aff9001b4b773e5ef0db
User & Date: js on 2008-11-05 17:51:12
Other Links: manifest | tags
Context
2008-11-05
18:22
More documentation. check-in: 1caf21d1b2 user: js tags: trunk
17:51
More documentation. check-in: 32ccf22a44 user: js tags: trunk
17:13
Start documenting stuff. check-in: 2690e9848f user: js tags: trunk
Changes

Modified src/OFArray.h from [ee707a5900] to [603616dc3f].

89
90
91
92
93
94
95






96
97
98
99
100






101








102







103
104






105
106
 * Removes the last items from the OFArray
 *
 * \param nitems The number of items to remove
 */
- removeNItems: (size_t)nitems;
@end







@interface OFBigArray: OFArray
{
	size_t size;
}







+ newWithItemSize: (size_t)is;








- initWithItemSize: (size_t)is;







- addNItems: (size_t)nitems
 fromCArray: (void*)carray;






- removeNItems: (size_t)nitems;
@end







>
>
>
>
>
>





>
>
>
>
>
>

>
>
>
>
>
>
>
>

>
>
>
>
>
>
>


>
>
>
>
>
>


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 * Removes the last items from the OFArray
 *
 * \param nitems The number of items to remove
 */
- removeNItems: (size_t)nitems;
@end

/**
 * The OFBigArray class is nearly the same as the OFArray class, but it
 * allocates the memory rather in pages than in bytes.
 * This is faster, but needs more memory. It is especially useful if you want
 * to store large hunks of data.
 */
@interface OFBigArray: OFArray
{
	size_t size;
}

/**
 * Creates a new OFBigArray whose items all have the same size.
 *
 * \param is The size of each element in the OFBigArray
 * \return A new allocated and initialized OFBigArray
 */
+ newWithItemSize: (size_t)is;

/**
 * Initializes an already allocated OFBigArray whose items all have the same
 * size.
 * 
 * \param is The size of each element in the OFBigArray
 * \return An initialized OFBigArray
 */
- initWithItemSize: (size_t)is;

/**
 * Adds items from a C array to the OFBigArray
 *
 * \param nitems The number of items to add
 * \param carray A C array containing the items to add
 */
- addNItems: (size_t)nitems
 fromCArray: (void*)carray;

/**
 * Removes the last items from the OFBigArray
 *
 * \param nitems The number of items to remove
 */
- removeNItems: (size_t)nitems;
@end

Modified src/OFObject.h from [d5d3bf61c7] to [1c8d9403e3].

14
15
16
17
18
19
20



21
22
23
24
25






26








27









28
29







30
31









32
33
34






35




36
37

struct __ofobject_allocated_mem {
	void				*ptr;
	struct __ofobject_allocated_mem *prev;
	struct __ofobject_allocated_mem *next;
};




@interface OFObject: Object
{
	struct __ofobject_allocated_mem *__mem_pool;
}







- init;








- (void*)getMemWithSize: (size_t)size;









- (void*)getMemForNItems: (size_t)nitems
		  ofSize: (size_t)size;







- (void*)resizeMem: (void*)ptr
	    toSize: (size_t)size;









- (void*)resizeMem: (void*)ptr
	  toNItems: (size_t)nitems
	    ofSize: (size_t)size;






- freeMem: (void*)ptr;




- free;
@end







>
>
>





>
>
>
>
>
>

>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>



>
>
>
>
>
>

>
>
>
>


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

struct __ofobject_allocated_mem {
	void				*ptr;
	struct __ofobject_allocated_mem *prev;
	struct __ofobject_allocated_mem *next;
};

/**
 * The OFObject class is the base class for all other classes inside ObjFW.
 */
@interface OFObject: Object
{
	struct __ofobject_allocated_mem *__mem_pool;
}

/**
 * Initialize the already allocated object.
 * Also sets up the memory pool for the object.
 *
 * \return An initialized object
 */
- init;

/**
 * Allocate memory and store it in the objects memory pool so it can be free'd
 * automatically when the object is free'd.
 *
 * \param size The size of the memory to allocate
 * \return A pointer to the allocated memory
 */
- (void*)getMemWithSize: (size_t)size;

/**
 * Allocate memory for a specified number of items and store it in the objects
 * memory pool so it can be free'd automatically when the object is free'd.
 *
 * \param nitems The number of items to allocate
 * \param size The size of each item to allocate
 * \return A pointer to the allocated memory
 */
- (void*)getMemForNItems: (size_t)nitems
		  ofSize: (size_t)size;

/**
 * Resize memory in the memory pool to a specified size.
 *
 * \param size The new size for the memory chunk
 * \return A pointer to the resized memory chunk
 */
- (void*)resizeMem: (void*)ptr
	    toSize: (size_t)size;

/**
 * Resize memory in the memory pool to a specific number of items of a
 * specified size.
 *
 * \param nitems The number of items to resize to
 * \param size The size of each item to resize to
 * \return A pointer to the resized memory chunk
 */
- (void*)resizeMem: (void*)ptr
	  toNItems: (size_t)nitems
	    ofSize: (size_t)size;

/**
 * Frees allocated memory and removes it from the memory pool.
 *
 * \param ptr A pointer to the allocated memory
 */
- freeMem: (void*)ptr;

/**
 * Frees the object and also frees all memory allocated via its memory pool.
 */
- free;
@end