Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
you know how it goes. you're 6 subroutines deep and suddenly you need a buffer. what do you do?

for me it depends on the kind of buffer. If I need an array of objects, I use 16. double digits, power of 2. seems reasonable enough.

if it's for a string, I use MAX_PATH. don't worry, I add a definition for non-Windows platforms. (the string does not have to be a file path.)

if I need a byte array, I grab 64kB. some people might use 1MB but that seems wasteful imo

Adbot
ADBOT LOVES YOU

The Management
Jan 2, 2010

sup, bitch?
CLINE_SIZE or PAGE_SIZE like a pro

akadajet
Sep 14, 2003

Gazpacho posted:

you know how it goes. you're 6 subroutines deep and suddenly you need a buffer. what do you do?

code:

var buffer = [];

Asymmetric POSTer
Aug 17, 2005

akadajet
Sep 14, 2003


gah, every time I need to take a piss she shows up

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
14kb :twisted:

Doc Block
Apr 15, 2003
Fun Shoe
i'm not a caveman so i avoid using c arrays directly

std::vector (or std::deque :clint: ) if i'm in the sewer writing code for the heathen platforms, or NSArray or NSMutableArray or NSData or whatever if I'm in a luxury condo writing code for the Good Operation Systems

pram
Jun 10, 2001

bathroom zamboni? lol

Farmer Crack-Ass
Jan 2, 2001

this is me posting irl

akadajet posted:

gah, every time I need to take a piss she shows up

she knows :tinfoil:

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

you should always choose either a power of two, or a power of two -1. that way anyone who looks will assume that theres some technical reason why you chose that size and you will look good

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Sweevo posted:

you should always choose either a power of two, or a power of two -1. that way anyone who looks will assume that theres some technical reason why you chose that size and you will look good

no you have to pick arbitrary numbers that make it look like you did a calculation

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

lol if you don't use a 69-byte buffer

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

219, 420, 1137, and 80085 are also acceptable

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
1000 bytes

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
what kind of buffer sizes do you get on a 36 bit computer

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'


turn in your badge, you're fired

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

i was honouring the entrants of the LIET minority language song contest

thats my story and i'm sticking to it

LP0 ON FIRE
Jan 25, 2006

beep boop
in swift or objective c i never really have to worry about this, but maybe an NSMutableArray/Dictionary

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i use my bespoke fixed page stack allocating buffer if it doesn't need to be returned to the caller.

otherwise its malloc(PAGE_SIZE)

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal
i just put stuff at random memory addresses and trust in the providence of the good lord that everything will be fine

worst case scenario there's a crash and the load gets redirected to other instances

it also confuses the hell out of hackers so that's good for security too

suffix
Jul 27, 2013

Wheeee!
code:
/* If you get random crashes try increasing this */
//static char tmpbuf[512];
//static char tmpbuf[530];
//static char tmpbuf[550];
// this seems to work DON'T TOUCH
//static char tmpbuf[566];
static char tmpbuf[512];

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Sweevo posted:

you should always choose either a power of two, or a power of two -1. that way anyone who looks will assume that theres some technical reason why you chose that size and you will look good

power of two plus one to maximize wasted space

Jimmy Carter
Nov 3, 2005

THIS MOTHERDUCKER
FLIES IN STYLE
the field for team abbreviation in ESPN Fantasy Baseball only supports 4 bytes and is homophobic
💑 sticks
👨‍❤️‍👨 gets changed to 👱

Sagebrush
Feb 26, 2012

I'm currently using a 29-byte buffer because the data I'm handling has a fixed 3-byte preamble and then goes into a register that's 32 bytes wide. Feels pretty good op

pram
Jun 10, 2001

suffix posted:

code:
/* If you get random crashes try increasing this */
//static char tmpbuf[512];
//static char tmpbuf[530];
//static char tmpbuf[550];
// this seems to work DON'T TOUCH
//static char tmpbuf[566];
static char tmpbuf[512];

lol

Sagebrush
Feb 26, 2012

quote:

When I worked at Planet Moon, we made an educational game for the Gameboy DS called BrainQuest. The DS only has 4MB of RAM, and toward the end of the project, we were running right up against that limit. When the final assets came in and were added to the package, we were just over the 4MB limit. One of the engineers grinned and walked over to his computer. He opened up main.cpp and commented out the following line:

code:
unsigned char insurance[10240];

The Management
Jan 2, 2010

sup, bitch?

suffix posted:

code:

/* If you get random crashes try increasing this */
//static char tmpbuf[512];
//static char tmpbuf[530];
//static char tmpbuf[550];
// this seems to work DON'T TOUCH
//static char tmpbuf[566];
static char tmpbuf[512];

murder this person

Bloody
Mar 3, 2013

256

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

LRECL=80, op

akadajet
Sep 14, 2003

suffix posted:

code:

/* If you get random crashes try increasing this */
//static char tmpbuf[512];
//static char tmpbuf[530];
//static char tmpbuf[550];
// this seems to work DON'T TOUCH
//static char tmpbuf[566];
static char tmpbuf[512];

5

ADINSX
Sep 9, 2003

Wanna run with my crew huh? Rule cyberspace and crunch numbers like I do?

akadajet posted:

gah, every time I need to take a piss she shows up

if you weren't such a messy pisser she wouldn't need a zamboni to clean up after you

ADINSX
Sep 9, 2003

Wanna run with my crew huh? Rule cyberspace and crunch numbers like I do?

also the answer is whatever the stackoverflow example code I find to solve my problem is using

Agile Vector
May 21, 2007

scrum bored



ADINSX posted:

if you weren't such a messy pisser she wouldn't need a zamboni to clean up after you

the proper term is maamboni

TOPS-420
Feb 13, 2012

code:

char answer[80];
puts("Name (max one line):");
gets(answer);

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
i use a buffer size of one dickabyte

being a programmer, of course, one dickabyte is

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Poopernickel posted:

i use a buffer size of one dickabyte

being a programmer, of course, one dickabyte is

whatever u fuckin typdef it to be

Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

you claim it's eight but it's actually 4.5 tops

jre
Sep 2, 2011

To the cloud ?



Sweevo posted:

you claim it's eight but it's actually 4.5 tops

burning swine
May 26, 2004



use whatever size you want just be polite about it

code:
	char buffer[1024];
	//thank you computer, keep this for urself
	malloc(1);
always tip the dealer

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=
always be heaping

  • Locked thread