Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nunc-stans malloc should be pluggable #1370

Closed
389-ds-bot opened this issue Sep 12, 2020 · 11 comments
Closed

nunc-stans malloc should be pluggable #1370

389-ds-bot opened this issue Sep 12, 2020 · 11 comments
Labels
closed: fixed Migration flag - Issue
Milestone

Comments

@389-ds-bot
Copy link

Cloned from Pagure issue: https://pagure.io/389-ds-base/issue/48039


apps need to be able to pass in malloc, calloc, etc. functions to use. For example, 389 needs nunc-stans to use slapi_ch_malloc, etc.

@389-ds-bot 389-ds-bot added the closed: fixed Migration flag - Issue label Sep 12, 2020
@389-ds-bot 389-ds-bot added this to the 1.3.4 backlog milestone Sep 12, 2020
@389-ds-bot
Copy link
Author

Comment from rmeggins (@richm) at 2015-02-26 23:31:42

Sorry - I forgot that the dirsrv signatures for slapi_ch_malloc etc. were non-standard. I think it would be better, more portable, more interoperable if nunc-stans used the standard signatures e.g.

       void *malloc(size_t size);
       void free(void *ptr);
       void *calloc(size_t nmemb, size_t size);
       void *realloc(void *ptr, size_t size);

Then dirsrv would need to provide functions using these signatures, and cast parameters and return values to size_t and char *.

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2015-02-27 01:08:33

New patches attached...

@389-ds-bot
Copy link
Author

Comment from rmeggins (@richm) at 2015-02-27 01:49:10

os_malloc(size_t size) 
 	82	{ 
 	83	        return malloc(size); 

Please use 4 spaces for indentation in nunc-stans.

 	1255	static char* 
 	1256	nunc_stans_malloc(size_t size) 
 	1257	{ 
 	1258	        return slapi_ch_malloc((unsigned long)size); 
 	1259	}

These functions should use the exact same signatures as nunc-stans (and system malloc, etc.) - so something like this:

static void * 
nunc_stans_malloc(size_t size) 
{ 
        return (void *)slapi_ch_malloc((unsigned long)size); 
}

static void *
nunc_stans_calloc(size_t count, size_t size)
{
        return (void *)slapi_ch_calloc((unsigned long)count, (unsigned long)size);
}

etc.

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2015-02-27 01:58:30

Replying to [comment:5 richm]:

os_malloc(size_t size) 
 	82	{ 
 	83	        return malloc(size); 

Please use 4 spaces for indentation in nunc-stans.

Whoops.

 	1255	static char* 
 	1256	nunc_stans_malloc(size_t size) 
 	1257	{ 
 	1258	        return slapi_ch_malloc((unsigned long)size); 
 	1259	}

These functions should use the exact same signatures as nunc-stans (and system malloc, etc.) - so something like this:

static void * 
nunc_stans_malloc(size_t size) 
{ 
        return (void *)slapi_ch_malloc((unsigned long)size); 
}

static void *
nunc_stans_calloc(size_t count, size_t size)
{
        return (void *)slapi_ch_calloc((unsigned long)count, (unsigned long)size);
}

etc.

My C book states that "char *", not "void *" is used for the alloc functions. But the linux man page says otherwise. I'll change it...

@389-ds-bot
Copy link
Author

@389-ds-bot
Copy link
Author

@389-ds-bot
Copy link
Author

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2015-02-27 02:11:15

Replying to [comment:7 richm]:

Not sure what book you have.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf - 7.20.3 Memory
management functions

I have "C: A reference manual" 5th edition. It states its C99 compliant, etc. I just bought it not that long ago, err.

Anyway, new patches are attached...

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2015-02-27 02:13:53

To git+ssh://git.engineering.redhat.com/srv/git/users/mareynol/ds.git
050299e..5ab764a nunc-stans -> nunc-stans
commit 5ab764ab17aa0edf214477b0da7123ba5d923b5e

To git+ssh://git.engineering.redhat.com/srv/git/users/mareynol/nunc-stans.git
5499cd4..c89dcbf mreynolds389 -> mreynolds389
commit c89dcbf94104d2ce92cc86ecee809a89b22dd508

@389-ds-bot
Copy link
Author

Comment from rmeggins (@richm) at 2015-04-30 23:21:10

nunc-stans part is now https://fedorahosted.org/nunc-stans/ticket/5

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2017-02-11 23:02:14

Metadata Update from @mreynolds389:

  • Issue assigned to mreynolds389
  • Issue set to the milestone: 1.3.4 backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: fixed Migration flag - Issue
Projects
None yet
Development

No branches or pull requests

1 participant