1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-14 12:23:52 +03:00
Commit Graph

48 Commits

Author SHA1 Message Date
Volker Lendecke
60ef9a84f0 Implement talloc_pool()
A talloc pool is a chunk of memory that can be used as a context for further
talloc calls. Allocations with the pool as the parent just chew from that
memory by incrementing a pointer. If the talloc pool is full, then we fall back
to the normal system-level malloc(3) to get memory.

The use case for talloc pools is the transient memory that is used for handling
a single SMB request. Incrementing a pointer will be way faster than any malloc
implementation.

There is a downside of this: If you use talloc_steal() to move something out of
the pool, the whole pool memory is kept around until the last object inside the
pool is freed. So if you talloc_free() the pool, it might happen that the
memory is freed later. So don't hang anything off a talloc pool that should
live long.

Volker
2008-02-11 15:07:46 +01:00
Stefan Metzmacher
2b2e841465 r25216: make talloc_append_string() a deprecated macro instead of
having it as a real function.

metze
2007-10-10 15:06:56 -05:00
Stefan Metzmacher
8532076720 r25208: add talloc_str[n]dup_append[_buffer]() functions
metze
2007-10-10 15:06:53 -05:00
Jeremy Allison
5bb8613b86 r25164: Add talloc_asprintf_append_buffer() and the docs for it.
Jeremy.
2007-10-10 15:06:44 -05:00
Andrew Tridgell
40c0919aaa r23798: updated old Temple Place FSF addresses to new URL 2007-10-10 14:59:15 -05:00
Andrew Tridgell
84b468b2f8 r23795: more v2->v3 conversion 2007-10-10 14:59:14 -05:00
Jeremy Allison
80706cf98d r22563: As tridge requested remove the _strict calls - for Samba3 I'm moving
to a separate file.
Jeremy.
2007-10-10 14:51:44 -05:00
Jeremy Allison
219e1cae77 r22541: Added talloc_size_strict macro.
Jeremy.
2007-10-10 14:51:40 -05:00
Jeremy Allison
ba1a66cc6f r22540: Added _strict varients of the macro calls - added
prototypes.
Jeremy.
2007-10-10 14:51:40 -05:00
Jeremy Allison
1ef269067c r22539: Added _strict varients of the talloc calls to
return NULL on size == 0 varients.
Jeremy.
2007-10-10 14:51:39 -05:00
Stefan Metzmacher
138ffd6d48 r22267: protect #define __location__ with an #ifndef
metze
2007-10-10 14:50:55 -05:00
Jelmer Vernooij
07652f65ce r21297: Remove the GTK+ tools and library from the main repository. They are now maintained separately in bzr at http://people.samba.org/bzr/jelmer/samba-gtk
This also adds some more headers to the list that is installed and a couple of extra #include lines so these
headers can be used externally without problems.
2007-10-10 14:48:04 -05:00
Stefan Metzmacher
85fc18f047 r20193: - let talloc_parent_chunk() handle a NULL pointer
- use talloc_parent_chunk() in talloc_parent_name()
- add prototype of talloc_parent_name()

metze
2007-10-10 14:29:21 -05:00
Andrew Tridgell
9b9f058edb r18521: implement volkers suggestion for avoiding the type punning warnings 2007-10-10 14:18:41 -05:00
Andrew Tridgell
254cbf09de r18439: 2nd try at a talloc_move() api. This type with the ** ptr interface
exposed.

Unfortunately this generates a large number of type punning
warnings. We'll have to find some magic to hide those.
2007-10-10 14:18:29 -05:00
Andrew Tridgell
200756017e r18435: added a function talloc_move() which is like talloc_steal(), but is
meant for moving pointers between structures. The difference is that
talloc_move() will zero the source pointer, thus ensuring you don't
reference the pointer in the old context.

talloc_move() is appropriate in some, but not all cases where we use
talloc_steal() now. The interface came out of a discussion with
Jeremy.
2007-10-10 14:18:29 -05:00
Stefan Metzmacher
b199557b35 r17907: - add a generic talloc_report_depth_cb() function which takes a callback
to do the actual report.
- make the talloc_report_depth_file() a wrapper of it
- and talloc_report() and talloc_report_full() are wrapper of
  talloc_report_depth_file()

metze
2007-10-10 14:16:54 -05:00
Stefan Metzmacher
933d1b47ad r17895: - talloc_increase_ref_count() can fail
- make talloc_reference() typesafe when gcc >= 3 is used

metze
2007-10-10 14:16:53 -05:00
Stefan Metzmacher
7cab4285b1 r17893: add a function to disable the null_context
metze
2007-10-10 14:16:52 -05:00
Stefan Metzmacher
fb73ce8d43 r17891: remove c++ warnings from talloc
metze
2007-10-10 14:16:52 -05:00
Stefan Metzmacher
bfca83c91e r17886: add talloc_ptrtype() and talloc_array_ptrtype(),
see the manpage what they do:-)

metze
2007-10-10 14:16:51 -05:00
Stefan Metzmacher
155cd6b882 r17885: use _TALLOC_TYPEPF() consitently
metze
2007-10-10 14:16:51 -05:00
Andrew Tridgell
8236a0ac5e r17645: gcc 4.1.x has started producing "value computed is not used" warnings
in very annoying ways for talloc_steal. This rather strange looking
cpp approach avoids these warnings. It's really a problem in gcc, but
better to do this than put up with the huge flood of warnings.
2007-10-10 14:16:19 -05:00
Stefan Metzmacher
195754b169 r17263: export talloc_free_children()
metze
2007-10-10 14:10:24 -05:00
Stefan Metzmacher
f47b7bb656 r17176: remove off_t from talloc. size_t is large enough to hold
the max amount of memory of one process

metze
2007-10-10 14:10:16 -05:00
Stefan Metzmacher
4c68e315e2 r16922: move some macros out of talloc.h as the don't belong to talloc
metze
2007-10-10 14:10:01 -05:00
Stefan Metzmacher
7aa07a1e0b r16446: talloc_set_name() allocates and can fail...
pass the error to the callers

metze
2007-10-10 14:09:15 -05:00
Andrew Tridgell
babbff5f77 r15852: patch from Rusty to make talloc_set_destructor() and talloc_steal()
type safe. This only works on recent gcc versions. With other
compilers it reverts to a non-typesafe cast

The patch also ensures that talloc_free() does not change error on
systems where free() can change errno
2007-10-10 14:08:32 -05:00
Andrew Tridgell
70531dcaee r15824: fixed a subtle talloc bug to do with memory context loops. When you
have a structure that references one of its parents, and a parent of
that parent is freed, then the whole structure should be freed, not
just the reference.

this was found by the change notify code, as a side effect of fixing
the memory leak yesterday
2007-10-10 14:08:28 -05:00
Andrew Tridgell
7a0e7074f6 r12633: expose talloc_vasprintf_append() 2007-10-10 13:49:10 -05:00
Andrew Tridgell
ed90975bf5 r11984: LGPL on header and testsuite as well 2007-10-10 13:46:55 -05:00
Simo Sorce
7ccf21ab4e r7936: new ldb_dn_explode and ldb_dn_casefold functions and co 2007-10-10 13:18:52 -05:00
Andrew Tridgell
5760ed20ee r7781: finding the parent of a talloc ptr is trickier than it looks due to the two-way
tree nature of the data structure. I think I've finally got it right

also added talloc_show_parents() for debugging
2007-10-10 13:18:36 -05:00
Andrew Tridgell
bdb55c7a10 r7778: added talloc_find_parent_bytype() and talloc_find_parent_byname()
These provide a way to find a parent of a ptr that is of a given
type. I will be using this to find the event context in smbd, relying
on the fact that everything is a child of the top level event
context. I did look at the alternatives, and found that passing the
event context to just about every call in smbd was getting way too
complex (we need to get it to anything that can do a ldb operation, as
that can invoke ldap).

So this method avoids a global, and seems to work nicely
2007-10-10 13:18:35 -05:00
Simo Sorce
df40184782 r6645: Add talloc_get_size() function.
Sometimes it is usefull to know this data.

Simo.
2007-10-10 13:16:32 -05:00
Andrew Tridgell
40b8ee186a r6075: added talloc_enable_null_tracking() (asked for by lifeless) 2007-10-10 13:11:17 -05:00
Andrew Tridgell
e25aa54e96 r5937: - performance improvement to talloc_asprintf_append()
- allow standalone talloc to use gcc printf attributes
2007-10-10 13:11:10 -05:00
Andrew Tridgell
c283e1a3ef r4790: added type checking helper macros in talloc. These take advantage of
the type names that talloc already keeps around for pointers, and
allows the user to type check void* private pointers. It can also be
used to implement polymorphism in C, as I'm sure someone would have
pointed out to me sooner or later :-)
2007-10-10 13:08:55 -05:00
Andrew Tridgell
4ec47cc108 r4711: - deprecate talloc_destroy()
- expanded the talloc_realloc() test a little (I was concerned about a
  possible bug, which turned out to be an illusion)

- don't enable gcov by default in Makefile.talloc
2007-10-10 13:08:46 -05:00
Stefan Metzmacher
9b9501bc03 r4689: - make talloc_report_depth() public
- add talloc_parent() to return the parent context of a pointer

these are very use full for debuging

metze
2007-10-10 13:08:43 -05:00
Stefan Metzmacher
a88aac7a39 r4687: use struct type and location for easier finding
metze
2007-10-10 13:08:43 -05:00
Stefan Metzmacher
11e006df16 r4609: add a usefull data_blob_dup_talloc() macro
metze
2007-10-10 13:08:33 -05:00
Andrew Tridgell
6e7754abd0 r4591: - converted the other _p talloc functions to not need _p
- added #if TALLOC_DEPRECATED around the _p functions

- fixes the code that broke from the above

while doing this I fixed quite a number of places that were
incorrectly using the non type-safe talloc functions to use the type
safe ones. Some were even doing multiplies for array allocation, which
is potentially unsafe.
2007-10-10 13:08:30 -05:00
Andrew Tridgell
2011bbeb84 r4550: talloc() is now typesafe. It is exactly equivalent to the old talloc_p() macro. Use
talloc_size() if you want the old behaviour.

I have kept talloc_p() as an alias for now. Once we change all calls
to be plain talloc() then we can remove it.
2007-10-10 13:08:26 -05:00
Andrew Tridgell
89b74b5354 r4549: got rid of a lot more uses of plain talloc(), instead using
talloc_size() or talloc_array_p() where appropriate.

also fixed a memory leak in pvfs_copy_file() (failed to free a memory
context)
2007-10-10 13:08:25 -05:00
Andrew Tridgell
e6c81d7c9f r4547: - added talloc_new(ctx) macro that is a neater form of the common talloc(ctx, 0) call.
- cleaned up some talloc usage in various files

I'd like to get to the point that we have no calls to talloc(), at
which point we will rename talloc_p() to talloc(), to encourage
everyone to use the typesafe functions.
2007-10-10 13:08:20 -05:00
Andrew Tridgell
cf73dda652 r4479: added the function talloc_autofree_context() which returns a talloc context that
will automatically be freed on program exit. This is useful for reducing
clutter in leak reports
2007-10-10 13:08:10 -05:00
Andrew Tridgell
98b5f73c1b r4473: - moved talloc into its own lib/talloc/ area
- added gcov flags to Makefile.talloc

- expanded talloc testsuite to add a test for realloc with a child ptr

- fixed a bug in talloc_realloc() with realloc of a ptr that has child ptrs
2007-10-10 13:07:55 -05:00